Class cc.TextureCache
Extends
cc.Class.
Defined in: CCTextureCache.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Implementation TextureCache
|
Method Attributes | Method Name and Description |
---|---|
addImage(path)
Returns a Texture2D object given an file image |
|
addImageAsync(path, target, selector)
Loading the images asynchronously
|
|
addPVRImage(path)
Returns a Texture2D object given an PVR filename |
|
AddPVRTCImage does not support
|
|
addUIImage(image, key)
Returns a Texture2D object given an UIImage image |
|
cacheImage(path, texture)
Cache the image data
|
|
ctor()
Constructor
|
|
Description
|
|
Output to cc.log the current contents of this TextureCache |
|
<static> |
cc.TextureCache.getInstance()
Return ths shared instance of the cache
|
getKeyByTexture(texture)
|
|
getTextureColors(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
|
|
textureForKey(key)
Returns an already created texture.
|
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}
//example cc.TextureCache.getInstance().addImageAsync("hello.png", this, this.loadingCallBack);
- Parameters:
- {String} path
- {cc.Node} target
- {Function} selector
- Returns:
- {Image}
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}
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}
- Parameters:
- {String} path
- {Image} texture
- Returns:
- {String}
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.
- Returns:
- {cc.TextureCache}
//example var key = cc.TextureCache.getInstance().getKeyByTexture(texture);
- Parameters:
- {Image} texture
- Returns:
- {String|Null}
//example var cacheTextureForColor = cc.TextureCache.getInstance().getTextureColors(texture);
- Parameters:
- {Image} texture
- Returns:
- {Array}
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();
//example cc.TextureCache.getInstance().removeTexture(texture);
- Parameters:
- {Image} texture
//example cc.TextureCache.getInstance().removeTexture("hello.png");
- Parameters:
- {String} textureKeyName
//example var key = cc.TextureCache.getInstance().textureForKey("hello.png");
- Parameters:
- {String} key
- Returns:
- {Image|Null}