cocos2d-x  2.2.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CCTextureCache Class Reference

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. More...

#include <CCTextureCache.h>

Inheritance diagram for CCTextureCache:
CCObject CCCopying

Public Member Functions

 CCTextureCache ()
 ctor ()
virtual ~CCTextureCache ()
const char * description (void)
CCDictionarysnapshotTextures ()
local snapshotTextures ()
CCTexture2DaddImage (const char *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. More...
 
var addImage ( var 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. More...
 
local addImage ( local 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. More...
 
void addImageAsync (const char *path, CCObject *target, SEL_CallFuncO selector)
local addImageAsync ( local path, local target, local selector)
CCTexture2DaddUIImage (CCImage *image, const char *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. More...
 
var addUIImage ( var image, var 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. More...
 
local addUIImage ( local image, local 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. More...
 
CCTexture2DtextureForKey (const char *key)
 Returns an already created texture. More...
 
local textureForKey ( local key)
 Returns an already created texture. More...
 
bool reloadTexture (const char *fileName)
 Reload texture from the image file If the file image hasn't loaded before, load it. More...
 
void removeAllTextures ()
 Purges the dictionary of loaded textures. More...
 
var removeAllTextures ()
 Purges the dictionary of loaded textures. More...
 
local removeAllTextures ()
 Purges the dictionary of loaded textures. More...
 
void removeUnusedTextures ()
 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. More...
 
var removeUnusedTextures ()
 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. More...
 
local removeUnusedTextures ()
 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. More...
 
void removeTexture (CCTexture2D *texture)
 Deletes a texture from the cache given a texture. More...
 
void removeTextureForKey (const char *textureKeyName)
 Deletes a texture from the cache given a its key name. More...
 
local removeTextureForKey ( local textureKeyName)
 Deletes a texture from the cache given a its key name. More...
 
void dumpCachedTextureInfo ()
 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. More...
 
local dumpCachedTextureInfo ()
 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. More...
 
CCTexture2DaddPVRImage (const char *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. More...
 
var addPVRImage ( var 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. More...
 
local addPVRImage ( local 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. More...
 
CCTexture2DaddETCImage (const char *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. More...
 
- Public Member Functions inherited from CCObject
 CCObject (void)
virtual ~CCObject (void)
void release (void)
void retain (void)
CCObjectautorelease (void)
CCObjectcopy (void)
bool isSingleReference (void) const
unsigned int retainCount (void) const
virtual bool isEqual (const CCObject *pObject)
virtual void acceptVisitor (CCDataVisitor &visitor)
virtual void update (float dt)
- Public Member Functions inherited from CCCopying
virtual CCObjectcopyWithZone (CCZone *pZone)

Static Public Member Functions

static CCTextureCachesharedTextureCache ()
 Returns the shared instance of the cache. More...
 
static void purgeSharedTextureCache ()
 purges the cache. More...
 
local purgeSharedTextureCache ()
 purges the cache. More...
 
static void reloadAllTextures ()
 Reload all textures It's only useful when the value of CC_ENABLE_CACHE_TEXTURE_DATA is 1. More...
 

Protected Attributes

CCDictionarym_pTextures
- Protected Attributes inherited from CCObject
unsigned int m_uReference
unsigned int m_uAutoReleaseCount

Additional Inherited Members

- Public Attributes inherited from CCObject
unsigned int m_uID
int m_nLuaID

Detailed Description

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.

Constructor & Destructor Documentation

var ctor ( )
virtual ~CCTextureCache ( )
virtual

Member Function Documentation

CCTexture2D* addETCImage ( const char *  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

var addETCImage ( var  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

CCTexture2D* addImage ( const char *  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

var addImage ( var  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

local addImage ( local  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

void addImageAsync ( const char *  path,
CCObject target,
SEL_CallFuncO  selector 
)
var addImageAsync ( var  path,
var  target,
var  selector 
)
local addImageAsync ( local  path,
local  target,
local  selector 
)
CCTexture2D* addPVRImage ( const char *  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

var addPVRImage ( var  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

local addPVRImage ( local  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

CCTexture2D* addUIImage ( CCImage image,
const char *  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.

var addUIImage ( var  image,
var  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.

local addUIImage ( local  image,
local  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.

const char* description ( void  )
void dumpCachedTextureInfo ( )

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.

Since
v1.0
var dumpCachedTextureInfo ( )

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.

Since
v1.0
local dumpCachedTextureInfo ( )

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.

Since
v1.0
static void purgeSharedTextureCache ( )
static

purges the cache.

It releases the retained instance.

Since
v0.99.0
var purgeSharedTextureCache ( )
static

purges the cache.

It releases the retained instance.

Since
v0.99.0
local purgeSharedTextureCache ( )
static

purges the cache.

It releases the retained instance.

Since
v0.99.0
static void reloadAllTextures ( )
static

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

var reloadAllTextures ( )
static

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

local reloadAllTextures ( )
static

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

bool reloadTexture ( const char *  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.

var reloadTexture ( var  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.

local reloadTexture ( local  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.

void removeAllTextures ( )

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

var removeAllTextures ( )

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

local removeAllTextures ( )

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

void removeTexture ( CCTexture2D texture)

Deletes a texture from the cache given a texture.

var removeTexture ( var  texture)

Deletes a texture from the cache given a texture.

local removeTexture ( local  texture)

Deletes a texture from the cache given a texture.

void removeTextureForKey ( const char *  textureKeyName)

Deletes a texture from the cache given a its key name.

Since
v0.99.4
var removeTextureForKey ( var  textureKeyName)

Deletes a texture from the cache given a its key name.

Since
v0.99.4
local removeTextureForKey ( local  textureKeyName)

Deletes a texture from the cache given a its key name.

Since
v0.99.4
void removeUnusedTextures ( )

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.

Since
v0.8
var removeUnusedTextures ( )

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.

Since
v0.8
local removeUnusedTextures ( )

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.

Since
v0.8
static CCTextureCache*
sharedTextureCache
( )
static

Returns the shared instance of the cache.

var getInstance ( )
static

Returns the shared instance of the cache.

local sharedTextureCache ( )
static

Returns the shared instance of the cache.

CCDictionary* snapshotTextures ( )
local snapshotTextures ( )
CCTexture2D* textureForKey ( const char *  key)

Returns an already created texture.

Returns nil if the texture doesn't exist.

Since
v0.99.5
var textureForKey ( var  key)

Returns an already created texture.

Returns nil if the texture doesn't exist.

Since
v0.99.5
local textureForKey ( local  key)

Returns an already created texture.

Returns nil if the texture doesn't exist.

Since
v0.99.5

Member Data Documentation

CCDictionary* m_pTextures
protected
var m_pTextures
protected
local m_pTextures
protected

The documentation for this class was generated from the following file: