Class CCTextureCache

#include <Geode/cocos/textures/CCTextureCache.h>
classCCTextureCache:publiccocos2d::CCObject{ ... }

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

Examples0
Public static methods4
staticcocos2d::CCTextureCache*sharedTextureCache()

Returns the shared instance of the cache

staticcocos2d::CCTextureCache*get()
No description provided
staticvoidpurgeSharedTextureCache()

Since v0.99.0

purges the cache. It releases the retained instance.

staticvoidreloadAllTextures()

Reload all textures It’s only useful when the value of CC_ENABLE_CACHE_TEXTURE_DATA is 1

Public member functions15
charconst*description()
No description provided
cocos2d::CCDictionary*snapshotTextures()
No description provided
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(,,,,)
No description provided
cocos2d::CCTexture2D*addUIImage(,)

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()

Since v0.99.5

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()

Since v0.8

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()

Deletes a texture from the cache given a texture

voidremoveTextureForKey(
charconst*textureKeyName
)

Since v0.99.4

Deletes a texture from the cache given a its key name

voiddumpCachedTextureInfo()

Since v1.0

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

voidprepareAsyncLoading()
No description provided
Fields1
;
No description provided
Protected member functions0
Protected fields0