A Animation object is used to perform animations on the Sprite objects. More...
#include <CCAnimation.h>
Public Member Functions | |
Animation () | |
virtual | ~Animation (void) |
bool | init () |
bool | initWithSpriteFrames (Array *pFrames, float delay=0.0f) |
Initializes a Animation with frames and a delay between frames. More... | |
bool | initWithAnimationFrames (Array *arrayOfAnimationFrames, float delayPerUnit, unsigned int loops) |
Initializes a Animation with AnimationFrame. More... | |
void | addSpriteFrame (SpriteFrame *pFrame) |
Adds a SpriteFrame to a Animation. More... | |
void | addSpriteFrameWithFile (const char *filename) |
Adds a frame with an image filename. More... | |
CC_DEPRECATED_ATTRIBUTE void | addSpriteFrameWithFileName (const char *filename) |
void | addSpriteFrameWithTexture (Texture2D *pobTexture, const Rect &rect) |
Adds a frame with a texture and a rect. More... | |
float | getTotalDelayUnits () const |
Gets the total Delay units of the Animation. More... | |
void | setDelayPerUnit (float delayPerUnit) |
Sets the delay in seconds of the "delay unit". More... | |
float | getDelayPerUnit () const |
Gets the delay in seconds of the "delay unit". More... | |
float | getDuration () const |
Gets the duration in seconds of the whole animation. More... | |
Array * | getFrames () const |
Gets the array of AnimationFrames. More... | |
void | setFrames (Array *frames) |
Sets the array of AnimationFrames. More... | |
bool | getRestoreOriginalFrame () const |
Checks whether to restore the original frame when animation finishes. More... | |
void | setRestoreOriginalFrame (bool restoreOriginalFrame) |
Sets whether to restore the original frame when animation finishes. More... | |
unsigned int | getLoops () const |
Gets the times the animation is going to loop. More... | |
void | setLoops (unsigned int loops) |
Sets the times the animation is going to loop. More... | |
virtual Animation * | clone () const override |
returns a copy of the object More... | |
Public Member Functions inherited from Object | |
Object () | |
Constructor. More... | |
virtual | ~Object () |
void | release () |
Release the ownership immediately. More... | |
void | retain () |
Retains the ownership. More... | |
Object * | autorelease () |
Release the ownership sometime soon automatically. More... | |
bool | isSingleReference () const |
Returns a boolean value that indicates whether there is only one reference to the object. More... | |
unsigned int | retainCount () const |
Returns the object's current reference count. More... | |
virtual bool | isEqual (const Object *object) |
Returns a boolean value that indicates whether this object and a given object are equal. More... | |
virtual void | acceptVisitor (DataVisitor &visitor) |
virtual void | update (float dt) |
Public Member Functions inherited from Clonable | |
virtual | ~Clonable () |
Object * | copy () const |
returns a copy of the object. More... | |
var | copy () |
returns a copy of the object. More... | |
local | copy () |
returns a copy of the object. More... | |
Static Public Member Functions | |
static Animation * | create (void) |
Creates an animation. More... | |
static Animation * | createWithSpriteFrames (Array *arrayOfSpriteFrameNames, float delay=0.0f) |
static Animation * | create (Array *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops=1) |
Protected Attributes | |
float | _totalDelayUnits |
total Delay units of the Animation. More... | |
float | _delayPerUnit |
Delay in seconds of the "delay unit". More... | |
float | _duration |
duration in seconds of the whole animation. More... | |
Array * | _frames |
array of AnimationFrames More... | |
bool | _restoreOriginalFrame |
whether or not it shall restore the original frame when the animation finishes More... | |
unsigned int | _loops |
how many times the animation is going to loop. More... | |
Protected Attributes inherited from Object | |
unsigned int | _reference |
count of references More... | |
unsigned int | _autoReleaseCount |
count of autorelease More... | |
Additional Inherited Members | |
Public Attributes inherited from Object | |
unsigned int | _ID |
object id, ScriptSupport need public _ID More... | |
int | _luaID |
Lua reference id. More... | |
A Animation object is used to perform animations on the Sprite objects.
The Animation object contains AnimationFrame objects, and a possible delay between the frames. You can animate a Animation object by using the Animate action. Example:
Animation | ( | ) |
|
virtual |
void addSpriteFrame | ( | SpriteFrame * | pFrame) |
Adds a SpriteFrame to a Animation.
The frame will be added with one "delay unit".
void addSpriteFrameWithFile | ( | const char * | filename) |
Adds a frame with an image filename.
Internally it will create a SpriteFrame and it will add it. The frame will be added with one "delay unit". Added to facilitate the migration from v0.8 to v0.9.
|
inline |
Adds a frame with a texture and a rect.
Internally it will create a SpriteFrame and it will add it. The frame will be added with one "delay unit". Added to facilitate the migration from v0.8 to v0.9.
|
overridevirtual |
returns a copy of the object
Implements Clonable.
|
static |
Creates an animation.
|
static |
|
static |
|
inline |
Gets the delay in seconds of the "delay unit".
float getDuration | ( | ) | const |
Gets the duration in seconds of the whole animation.
It is the result of totalDelayUnits * delayPerUnit
|
inline |
Gets the array of AnimationFrames.
|
inline |
Gets the times the animation is going to loop.
0 means animation is not animated. 1, animation is executed one time, ...
|
inline |
Checks whether to restore the original frame when animation finishes.
|
inline |
Gets the total Delay units of the Animation.
bool init | ( | ) |
bool initWithAnimationFrames | ( | Array * | arrayOfAnimationFrames, |
float | delayPerUnit, | ||
unsigned int | loops | ||
) |
Initializes a Animation with AnimationFrame.
bool initWithSpriteFrames | ( | Array * | pFrames, |
float | delay = 0.0f |
||
) |
Initializes a Animation with frames and a delay between frames.
|
inline |
Sets the delay in seconds of the "delay unit".
|
inline |
Sets the array of AnimationFrames.
|
inline |
Sets the times the animation is going to loop.
0 means animation is not animated. 1, animation is executed one time, ...
|
inline |
Sets whether to restore the original frame when animation finishes.
|
protected |
Delay in seconds of the "delay unit".
|
protected |
duration in seconds of the whole animation.
It is the result of totalDelayUnits * delayPerUnit
|
protected |
array of AnimationFrames
|
protected |
how many times the animation is going to loop.
0 means animation is not animated. 1, animation is executed one time, ...
|
protected |
whether or not it shall restore the original frame when the animation finishes
|
protected |
total Delay units of the Animation.