加载图片到缓存

把图片加载到缓存,加载完成后,并回调对应的方法

bool LoadingLayer::init(){
	bool isRet=false;
	do 
	{
	CC_BREAK_IF(!BaseLayer::init());
	
	CCTextureCache::sharedTextureCache()->addImageAsync("welcomebg.png",this,callfuncO_selector(LoadingLayer::loadCallBack)); // 加载图片到缓存
	isRet=true;
	} while (0);
	return isRet;
}

void LoadingLayer::loadCallBack(CCObject* ped){
	// 加载完成时回调
        // 回调代码.........

        // 从缓存中 取出 背景图片
	CCTexture2D* texturebg=  CCTextureCache::sharedTextureCache()->textureForKey("welcomebg.png");
	CCSprite* pSpriteBg=CCSprite::createWithTexture(texturebg);
}


你可能感兴趣的:(加载图片到缓存)