Class Index | File Index

Classes


Class cc.TextureCache


Extends cc.Class.

Defined in: CCTextureCache.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Implementation TextureCache
Method Summary
Method Attributes Method Name and Description
 
addImage(path)

Returns a Texture2D object given an file image
If the file image was not previously loaded, it will create a new Texture2D
object and it will return it.

 
addImageAsync(path, target, selector)
Loading the images asynchronously
 

Returns a Texture2D object given an PVR filename
If the file image was not previously loaded, it will create a new Texture2D
object and it will return it.

 
AddPVRTCImage does not support
 
addUIImage(image, key)

Returns a Texture2D object given an UIImage image
If the image was not previously loaded, it will create a new Texture2D object and it will return it.

 
cacheImage(path, texture)
Cache the image data
 
ctor()
Constructor
 
Description
 

Output to cc.log the current contents of this TextureCache
This will attempt to calculate the size of each texture, and the total texture memory in use.

<static>  
cc.TextureCache.getInstance()
Return ths shared instance of the cache
 
getKeyByTexture(texture)
 
<static>  
cc.TextureCache.purgeSharedTextureCache()
Purges the cache.
 

Purges the dictionary of loaded textures.

 
removeTexture(texture)
Deletes a texture from the cache given a texture
 
removeTextureForKey(textureKeyName)
Deletes a texture from the cache given a its key name
 
Returns an already created texture.
Class Detail
cc.TextureCache()
Implementation TextureCache
Method Detail
{Image} addImage(path)

Returns a Texture2D object given an file image
If the file image was not previously loaded, it will create a new Texture2D
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, .jpg, .gif

//example
cc.TextureCache.getInstance().addImage("hello.png");
Parameters:
{String} path
Returns:
{Image}

{Image} addImageAsync(path, target, selector)
Loading the images asynchronously
//example
cc.TextureCache.getInstance().addImageAsync("hello.png", this, this.loadingCallBack);
Parameters:
{String} path
{cc.Node} target
{Function} selector
Returns:
{Image}

{cc.Texture2D} addPVRImage(path)

Returns a Texture2D object given an PVR filename
If the file image was not previously loaded, it will create a new Texture2D
object and it will return it. Otherwise it will return a reference of a previously loaded image

Parameters:
{String} path
Returns:
{cc.Texture2D}

addPVRTCImage()
AddPVRTCImage does not support

{cc.Texture2D} addUIImage(image, key)

Returns a Texture2D object given an UIImage image
If the image was not previously loaded, it will create a new Texture2D 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 null, then a new texture will be created each time.

Parameters:
{Image} image
{String} key
Returns:
{cc.Texture2D}

cacheImage(path, texture)
Cache the image data
Parameters:
{String} path
{Image} texture

ctor()
Constructor

{String} description()
Description
Returns:
{String}

dumpCachedTextureInfo()

Output to cc.log the current contents of this TextureCache
This will attempt to calculate the size of each texture, and the total texture memory in use.


<static> {cc.TextureCache} cc.TextureCache.getInstance()
Return ths shared instance of the cache
Returns:
{cc.TextureCache}

{String|Null} getKeyByTexture(texture)
//example
var key = cc.TextureCache.getInstance().getKeyByTexture(texture);
Parameters:
{Image} texture
Returns:
{String|Null}

{Array} getTextureColors(texture)
//example
var cacheTextureForColor = cc.TextureCache.getInstance().getTextureColors(texture);
Parameters:
{Image} texture
Returns:
{Array}

<static> cc.TextureCache.purgeSharedTextureCache()
Purges the cache. It releases the retained instance.

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

//example
cc.TextureCache.getInstance().removeAllTextures();

removeTexture(texture)
Deletes a texture from the cache given a texture
//example
cc.TextureCache.getInstance().removeTexture(texture);
Parameters:
{Image} texture

removeTextureForKey(textureKeyName)
Deletes a texture from the cache given a its key name
//example
cc.TextureCache.getInstance().removeTexture("hello.png");
Parameters:
{String} textureKeyName

{Image|Null} textureForKey(key)
Returns an already created texture. Returns null if the texture doesn't exist.
//example
var key = cc.TextureCache.getInstance().textureForKey("hello.png");
Parameters:
{String} key
Returns:
{Image|Null}

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Jan 09 2013 07:51:54 GMT-0800 (PST)