cocos2d-x  2.2.3-gd2.113-rev1ec524e
Loading...
Searching...
No Matches
CCSpriteFrameCache Class Reference

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

#include <CCSpriteFrameCache.h>

Inheritance diagram for CCSpriteFrameCache:
[legend]
Collaboration diagram for CCSpriteFrameCache:
[legend]

Public Member Functions

bool init (void)
 
 ~CCSpriteFrameCache (void)
 NA NA. More...
 
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)
 NA. More...
 
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)
 
 CCObject (const CCObject &)
 
CCObjectoperator= (const CCObject &)
 
virtual void encodeWithCoder (DS_Dictionary *)
 
virtual bool canEncode ()
 
CCObjectType getObjType () const
 
virtual int getTag () const
 
virtual void setTag (int nTag)
 
void setObjType (CCObjectType)
 
- 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 getInstance. More...
 
static void purgeSharedSpriteFrameCache (void)
 Purges the cache. More...
 
- Static Public Member Functions inherited from CCObject
static CCObjectcreateWithCoder (DS_Dictionary *)
 

Protected Member Functions

 CCSpriteFrameCache (void)
 ctor More...
 

Protected Attributes

CCDictionarym_pSpriteFrames
 
CCDictionarym_pSpriteFramesAliases
 
std::set< std::string > * m_pLoadedFileNames
 
- Protected Attributes inherited from CCObject
unsigned int m_uReference
 
unsigned int m_uAutoReleaseCount
 
int m_nTag
 
int m_eObjType
 
unsigned int m_uObjectIdxInArray
 

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()

CCSpriteFrameCache ( void  )
inlineprotected

ctor

◆ ~CCSpriteFrameCache()

~CCSpriteFrameCache ( void  )

NA NA.

Member Function Documentation

◆ addSpriteFrame()

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.

◆ addSpriteFramesWithFile() [1/3]

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 addSpriteFrames

◆ addSpriteFramesWithFile() [2/3]

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

◆ addSpriteFramesWithFile() [3/3]

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

◆ init()

bool init ( void  )

◆ purgeSharedSpriteFrameCache()

static void purgeSharedSpriteFrameCache ( void  )
static

Purges the cache.

It releases all the Sprite Frames and the retained instance.

◆ removeSpriteFrameByName()

void removeSpriteFrameByName ( const char *  pszName)

Deletes an sprite frame from the sprite frame cache.

getSpriteFrame

◆ removeSpriteFrames()

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.

◆ removeSpriteFramesFromFile()

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

◆ removeSpriteFramesFromTexture()

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.

◆ removeUnusedSpriteFrames()

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.

◆ sharedSpriteFrameCache()

static CCSpriteFrameCache * sharedSpriteFrameCache ( void  )
static

Returns the shared instance of the Sprite Frame cache getInstance.

◆ spriteFrameByName()

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

Member Data Documentation

◆ m_pLoadedFileNames

std::set<std::string>* m_pLoadedFileNames
protected

◆ m_pSpriteFrames

CCDictionary* m_pSpriteFrames
protected

◆ m_pSpriteFramesAliases

CCDictionary* m_pSpriteFramesAliases
protected

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