Cocos2d-x  v4
AnimationCache Class Reference

Singleton that manages the Animations. More...

Inherits Ref.

Public Member Functions

 AnimationCache ()
 @js ctor
 
 ~AnimationCache ()
 @js NA @lua NA
 
void addAnimation (Animation *animation, const std::string &name)
 Adds a Animation with a name. More...
 
void removeAnimation (const std::string &name)
 Deletes a Animation from the cache. More...
 
AnimationgetAnimation (const std::string &name)
 Returns a Animation that was previously added. More...
 
void addAnimationsWithDictionary (const ValueMap &dictionary, const std::string &plist)
 Adds an animation from an NSDictionary. More...
 
void addAnimationsWithFile (const std::string &plist)
 Adds an animation from a plist file. More...
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 Destructor. More...
 

Static Public Member Functions

static AnimationCachegetInstance ()
 Returns the shared instance of the Animation cache @js NA.
 
static void destroyInstance ()
 Purges the cache. More...
 

Additional Inherited Members

- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 

Detailed Description

Singleton that manages the Animations.

It saves in a cache the animations. You should use this class if you want to save your animations in a cache.

Before v0.99.5, the recommend way was to save them on the Sprite. Since v0.99.5, you should use this class instead.

Since
v0.99.5 @js cc.animationCache

Member Function Documentation

◆ destroyInstance()

static void destroyInstance ( )
static

Purges the cache.

It releases all the Animation objects and the shared instance. @js NA

◆ addAnimation()

void addAnimation ( Animation animation,
const std::string &  name 
)

Adds a Animation with a name.

Parameters
animationAn animation.
nameThe name of animation.

◆ removeAnimation()

void removeAnimation ( const std::string &  name)

Deletes a Animation from the cache.

Parameters
nameThe name of animation.

◆ getAnimation()

Animation* getAnimation ( const std::string &  name)

Returns a Animation 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.

Returns
A Animation that was previously added. If the name is not found it will return nil.

◆ addAnimationsWithDictionary()

void addAnimationsWithDictionary ( const ValueMap &  dictionary,
const std::string &  plist 
)

Adds an animation from an NSDictionary.

Make sure that the frames were previously loaded in the SpriteFrameCache.

Parameters
dictionaryAn NSDictionary.
plistThe path of the relative file,it use to find the plist path for load SpriteFrames.
Since
v1.1 @js NA

◆ addAnimationsWithFile()

void addAnimationsWithFile ( const std::string &  plist)

Adds an animation from a plist file.

Make sure that the frames were previously loaded in the SpriteFrameCache.

Since
v1.1 @js addAnimations @lua addAnimations
Parameters
plistAn animation from a plist file.

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