Namespace cc.textureCache
The global cache for cc.Texture2D
- Defined in: CCTextureCache.js
Method Summary
Method Detail
-
{cc.Texture2D} addETCImage(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
note:addETCImage does not support on HTML5- Parameters:
- {String} filename
- Returns:
- {cc.Texture2D}
-
{cc.Texture2D} addImage(url, target, cb)
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.addImage("hello.png");
- Parameters:
- {String} url
- target
- cb
- Returns:
- {cc.Texture2D}
-
{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}
-
{cc.Texture2D} addPVRTCImage(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
note: AddPVRTCImage does not support on HTML5- Parameters:
- {String} filename
- Returns:
- {cc.Texture2D}
-
{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:
- {HTMLImageElement|HTMLCanvasElement} image
- {String} key
- Returns:
- {cc.Texture2D}
-
cacheImage(path, texture)Cache the image data
- Parameters:
- {String} path
- {Image|HTMLImageElement|HTMLCanvasElement} texture
-
{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. -
{String|Null} getKeyByTexture(texture)
//example var key = cc.textureCache.getKeyByTexture(texture);
- Parameters:
- {Image} texture
- Returns:
- {String|Null}
-
{Array} getTextureColors(texture)
//example var cacheTextureForColor = cc.textureCache.getTextureColors(texture);
- Parameters:
- {Image} texture
- Returns:
- {Array}
-
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.removeAllTextures();
-
removeTexture(texture)Deletes a texture from the cache given a texture
//example cc.textureCache.removeTexture(texture);
- Parameters:
- {Image} texture
-
removeTextureForKey(textureKeyName)Deletes a texture from the cache given a its key name
//example cc.textureCache.removeTexture("hello.png");
- Parameters:
- {String} textureKeyName
-
{cc.Texture2D|Null} textureForKey(textureKeyName)Returns an already created texture. Returns null if the texture doesn't exist.
//example var key = cc.textureCache.textureForKey("hello.png");
- Parameters:
- {String} textureKeyName
- Returns:
- {cc.Texture2D|Null}