Class Index | File Index

Classes


Class cc.SpriteFrameCache


Extends cc.Class.

Defined in: CCSpriteFrameCache.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Singleton that handles the loading of the sprite frames.
Method Summary
Method Attributes Method Name and Description
 
addSpriteFrame(frame, frameName)

Adds an sprite frame with a given name.

 
addSpriteFrames(plist, texture)

Adds multiple Sprite Frames from a plist file.

 
Adds multiple Sprite Frames from a json file.
 
ctor()
Constructor
<static>  
cc.SpriteFrameCache.getInstance()
Returns the shared instance of the Sprite Frame cache
 

Returns an Sprite Frame that was previously added.

<static>  
cc.SpriteFrameCache.purgeSharedSpriteFrameCache()
Purges the cache.
 
Deletes an sprite frame from the sprite frame cache.
 

Purges the dictionary of loaded sprite frames.

 

Removes multiple Sprite Frames from a plist file.

 

Removes all Sprite Frames associated with the specified textures.

Class Detail
cc.SpriteFrameCache()
Singleton that handles the loading of the sprite frames. It saves in a cache the sprite frames.
// add SpriteFrames to SpriteFrameCache With File
cc.SpriteFrameCache.getInstance().addSpriteFrames(s_grossiniPlist);
Method Detail
addSpriteFrame(frame, frameName)

Adds an sprite frame with a given name.
If the name already exists, then the contents of the old name will be replaced with the new one.

Parameters:
{cc.SpriteFrame} frame
{String} frameName

addSpriteFrames(plist, texture)

Adds multiple Sprite Frames from a plist file.
A texture will be loaded automatically. The texture name will composed by replacing the .plist suffix with .png
If you want to use another texture, you should use the addSpriteFrames:texture method.

// add SpriteFrames to SpriteFrameCache With File
cc.SpriteFrameCache.getInstance().addSpriteFrames(s_grossiniPlist);
Parameters:
{String} plist
plist filename
{HTMLImageElement|cc.Texture2D} texture

addSpriteFramesWithJson(jsonData)
Adds multiple Sprite Frames from a json file. A texture will be loaded automatically.
Parameters:
{object} jsonData

ctor()
Constructor

<static> {cc.SpriteFrameCache} cc.SpriteFrameCache.getInstance()
Returns the shared instance of the Sprite Frame cache
Returns:
{cc.SpriteFrameCache}

{cc.SpriteFrame} getSpriteFrame(name)

Returns an Sprite Frame that was previously added.
If the name is not found it will return nil.
You should retain the returned copy if you are going to use it.

//get a SpriteFrame by name
var frame = cc.SpriteFrameCache.getInstance().getSpriteFrame("grossini_dance_01.png");
Parameters:
{String} name
name of SpriteFrame
Returns:
{cc.SpriteFrame}

<static> cc.SpriteFrameCache.purgeSharedSpriteFrameCache()
Purges the cache. It releases all the Sprite Frames and the retained instance.

removeSpriteFrameByName(name)
Deletes an sprite frame from the sprite frame cache.
Parameters:
{String} name

removeSpriteFrames()

Purges the dictionary of loaded sprite frames.
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.


removeSpriteFramesFromFile(plist)

Removes multiple Sprite Frames from a plist file.
Sprite Frames stored in this file will be removed.
It is convinient to call this method when a specific texture needs to be removed.

Parameters:
{String} plist
plist filename

removeSpriteFramesFromTexture(texture)

Removes all Sprite Frames associated with the specified textures.
It is convinient to call this method when a specific texture needs to be removed.

Parameters:
{HTMLImageElement|HTMLCanvasElement|cc.Texture2D} texture

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