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

Singleton that handles the loading of the sprite frames. More...

#include <CCSpriteFrameCache.h>

Inheritance diagram for CCSpriteFrameCache:
CCObject CCCopying

Public Member Functions

bool init (void)
 ~CCSpriteFrameCache (void)
void addSpriteFramesWithFile (const char *pszPlist)
 Adds multiple Sprite Frames from a plist file. More...
 
void addSpriteFramesWithFile (const char *plist, const char *textureFileName)
 Adds multiple Sprite Frames from a plist file. More...
 
void addSpriteFramesWithFile (const char *pszPlist, CCTexture2D *pobTexture)
 Adds multiple Sprite Frames from a plist file. More...
 
void addSpriteFrame (CCSpriteFrame *pobFrame, const char *pszFrameName)
 Adds an sprite frame with a given name. More...
 
void removeSpriteFrames (void)
 Purges the dictionary of loaded sprite frames. More...
 
void removeUnusedSpriteFrames (void)
 Removes unused sprite frames. More...
 
void removeSpriteFrameByName (const char *pszName)
 Deletes an sprite frame from the sprite frame cache. More...
 
void removeSpriteFramesFromFile (const char *plist)
 Removes multiple Sprite Frames from a plist file. More...
 
void removeSpriteFramesFromTexture (CCTexture2D *texture)
 Removes all Sprite Frames associated with the specified textures. More...
 
CCSpriteFramespriteFrameByName (const char *pszName)
 Returns an Sprite Frame that was previously added. 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 CCSpriteFrameCachesharedSpriteFrameCache (void)
 Returns the shared instance of the Sprite Frame cache. More...
 
local sharedSpriteFrameCache ()
 Returns the shared instance of the Sprite Frame cache. More...
 
static void purgeSharedSpriteFrameCache (void)
 Purges the cache. More...
 

Protected Member Functions

 CCSpriteFrameCache (void)

Protected Attributes

CCDictionarym_pSpriteFrames
CCDictionarym_pSpriteFramesAliases
var m_pSpriteFramesAliases
local m_pSpriteFramesAliases
std::set< std::string > * m_pLoadedFileNames
var m_pLoadedFileNames
local m_pLoadedFileNames
- 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 the sprite frames.

It saves in a cache the sprite frames.

Since
v0.9

Constructor & Destructor Documentation

CCSpriteFrameCache ( void  )
inlineprotected
var ctor (   )
inlineprotected
local CCSpriteFrameCache (   )
inlineprotected
~CCSpriteFrameCache ( void  )

Member Function Documentation

void addSpriteFrame ( CCSpriteFrame pobFrame,
const char *  pszFrameName 
)

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.

var addSpriteFrame ( var  pobFrame,
var  pszFrameName 
)

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.

local addSpriteFrame ( local  pobFrame,
local  pszFrameName 
)

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.

void addSpriteFramesWithFile ( const char *  pszPlist)

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 addSpriteFramesWithFile:texture method.

var addSpriteFrames ( var  pszPlist)

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 addSpriteFramesWithFile:texture method.

local addSpriteFramesWithFile ( local  pszPlist)

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 addSpriteFramesWithFile:texture method.

void addSpriteFramesWithFile ( const char *  plist,
const char *  textureFileName 
)

Adds multiple Sprite Frames from a plist file.

The texture will be associated with the created sprite frames.

Since
v0.99.5
var addSpriteFrames ( var  plist,
var  textureFileName 
)

Adds multiple Sprite Frames from a plist file.

The texture will be associated with the created sprite frames.

Since
v0.99.5
local addSpriteFramesWithFile ( local  plist,
local  textureFileName 
)

Adds multiple Sprite Frames from a plist file.

The texture will be associated with the created sprite frames.

Since
v0.99.5
void addSpriteFramesWithFile ( const char *  pszPlist,
CCTexture2D pobTexture 
)

Adds multiple Sprite Frames from a plist file.

The texture will be associated with the created sprite frames.

var addSpriteFrames ( var  pszPlist,
var  pobTexture 
)

Adds multiple Sprite Frames from a plist file.

The texture will be associated with the created sprite frames.

local addSpriteFramesWithFile ( local  pszPlist,
local  pobTexture 
)

Adds multiple Sprite Frames from a plist file.

The texture will be associated with the created sprite frames.

bool init ( void  )
var init (   )
local init (   )
static void
purgeSharedSpriteFrameCache
( void  )
static

Purges the cache.

It releases all the Sprite Frames and the retained instance.

var purgeSharedSpriteFrameCache (   )
static

Purges the cache.

It releases all the Sprite Frames and the retained instance.

local purgeSharedSpriteFrameCache (   )
static

Purges the cache.

It releases all the Sprite Frames and the retained instance.

void removeSpriteFrameByName ( const char *  pszName)

Deletes an sprite frame from the sprite frame cache.

var getSpriteFrame ( var  pszName)

Deletes an sprite frame from the sprite frame cache.

local removeSpriteFrameByName ( local  pszName)

Deletes an sprite frame from the sprite frame cache.

void removeSpriteFrames ( void  )

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.

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

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

void removeSpriteFramesFromFile ( const char *  plist)

Removes multiple Sprite Frames from a plist file.

Sprite Frames stored in this file will be removed. It is convenient to call this method when a specific texture needs to be removed.

Since
v0.99.5
var removeSpriteFramesFromFile ( var  plist)

Removes multiple Sprite Frames from a plist file.

Sprite Frames stored in this file will be removed. It is convenient to call this method when a specific texture needs to be removed.

Since
v0.99.5
local removeSpriteFramesFromFile ( local  plist)

Removes multiple Sprite Frames from a plist file.

Sprite Frames stored in this file will be removed. It is convenient to call this method when a specific texture needs to be removed.

Since
v0.99.5
void removeSpriteFramesFromTexture ( CCTexture2D texture)

Removes all Sprite Frames associated with the specified textures.

It is convenient to call this method when a specific texture needs to be removed.

Since
v0.995.
var removeSpriteFramesFromTexture ( var  texture)

Removes all Sprite Frames associated with the specified textures.

It is convenient to call this method when a specific texture needs to be removed.

Since
v0.995.
local removeSpriteFramesFromTexture ( local  texture)

Removes all Sprite Frames associated with the specified textures.

It is convenient to call this method when a specific texture needs to be removed.

Since
v0.995.
void removeUnusedSpriteFrames ( void  )

Removes unused sprite frames.

Sprite Frames that have a retain count of 1 will be deleted. It is convenient to call this method after when starting a new Scene.

var removeUnusedSpriteFrames (   )

Removes unused sprite frames.

Sprite Frames that have a retain count of 1 will be deleted. It is convenient to call this method after when starting a new Scene.

local removeUnusedSpriteFrames (   )

Removes unused sprite frames.

Sprite Frames that have a retain count of 1 will be deleted. It is convenient to call this method after when starting a new Scene.

static CCSpriteFrameCache*
sharedSpriteFrameCache
( void  )
static

Returns the shared instance of the Sprite Frame cache.

var getInstance (   )
static

Returns the shared instance of the Sprite Frame cache.

local sharedSpriteFrameCache (   )
static

Returns the shared instance of the Sprite Frame cache.

CCSpriteFrame* spriteFrameByName ( const char *  pszName)

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.

var getSpriteFrame ( var  pszName)

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.

local spriteFrameByName ( local  pszName)

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.

Member Data Documentation

std::set<std::string>
* m_pLoadedFileNames
protected
var m_pLoadedFileNames
protected
local m_pLoadedFileNames
protected
CCDictionary* m_pSpriteFrames
protected
var m_pSpriteFrames
protected
local m_pSpriteFrames
protected
CCDictionary*
m_pSpriteFramesAliases
protected
var m_pSpriteFramesAliases
protected
local m_pSpriteFramesAliases
protected

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