Singleton that handles the loading of textures Once the texture is loaded, the next time it will return a reference of the previously loaded texture reducing GPU & CPU memory
Class CCTextureCache
#include <Geode/cocos/textures/CCTextureCache.h>
Examples0
Public static methods4
staticcocos2d::CCTextureCache*get()
staticvoidreloadAllTextures()
Reload all textures It’s only useful when the value of CC_ENABLE_CACHE_TEXTURE_DATA is 1
Public member functions15
charconst*description()
cocos2d::CCDictionary*snapshotTextures()
cocos2d::CCTexture2D*addImage(charconst*fileimage,)
Returns a Texture2D object given an file image If the file image was not previously loaded, it will create a new CCTexture2D object and it will return it. It will use the filename as a key. Otherwise it will return a reference of a previously loaded image. Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr, .gif
ℹ Robtop Addition: added a bool param
voidaddImageAsync(,,,,)
cocos2d::CCTexture2D*addUIImage(cocos2d::CCImage*image,charconst*key)
Returns a Texture2D object given an UIImage image If the image was not previously loaded, it will create a new CCTexture2D object and it will return it. Otherwise it will return a reference of a previously loaded image The “key” parameter will be used as the “key” for the cache. If “key” is nil, then a new texture will be created each time.
cocos2d::CCTexture2D*textureForKey(charconst*key)
Returns an already created texture. Returns nil if the texture doesn’t exist.
boolreloadTexture(charconst*fileName)
Reload texture from the image file If the file image hasn’t loaded before, load it. Otherwise the texture will be reloaded from the file image. The “filenName” parameter is the related/absolute path of the file image. Return true if the reloading is succeed, otherwise return false.
voidremoveAllTextures()
Purges the dictionary of loaded textures. Call this method if you receive the “Memory Warning” In the short term: it will free some resources preventing your app from being killed In the medium term: it will allocate more resources In the long term: it will be the same
voidremoveUnusedTextures()
Removes unused textures Textures that have a retain count of 1 will be deleted It is convenient to call this method after when starting a new Scene
voidremoveTexture(cocos2d::CCTexture2D*texture)
Deletes a texture from the cache given a texture
voidremoveTextureForKey(charconst*textureKeyName)
Deletes a texture from the cache given a its key name
voiddumpCachedTextureInfo()
Output to CCLOG the current contents of this CCTextureCache This will attempt to calculate the size of each texture, and the total texture memory in use
cocos2d::CCTexture2D*addPVRImage(charconst*filename)
Returns a Texture2D object given an PVR filename If the file image was not previously loaded, it will create a new CCTexture2D object and it will return it. Otherwise it will return a reference of a previously loaded image
cocos2d::CCTexture2D*addETCImage(charconst*filename)
Returns a Texture2D object given an ETC filename If the file image was not previously loaded, it will create a new CCTexture2D object and it will return it. Otherwise it will return a reference of a previously loaded image