Axmol Engine 2.4.0-258ceca
Loading...
Searching...
No Matches
Animation Class Reference

A Animation object is used to perform animations on the Sprite objects. More...

#include <Animation.h>

Inherits Object, and Clonable.

Public Member Functions

void addSpriteFrame (SpriteFrame *frame)
 Adds a SpriteFrame to a Animation.
 
void addSpriteFrameWithFile (std::string_view filename)
 Adds a frame with an image filename.
 
void addSpriteFrameWithTexture (Texture2D *pobTexture, const Rect &rect)
 Adds a frame with a texture and a rect.
 
float getTotalDelayUnits () const
 Gets the total Delay units of the Animation.
 
void setDelayPerUnit (float delayPerUnit)
 Sets the delay in seconds of the "delay unit".
 
float getDelayPerUnit () const
 Gets the delay in seconds of the "delay unit".
 
float getDuration () const
 Gets the duration in seconds of the whole animation.
 
const Vector< AnimationFrame * > & getFrames () const
 Gets the array of AnimationFrames.
 
void setFrames (const Vector< AnimationFrame * > &frames)
 Sets the array of AnimationFrames.
 
bool getRestoreOriginalFrame () const
 Checks whether to restore the original frame when animation finishes.
 
void setRestoreOriginalFrame (bool restoreOriginalFrame)
 Sets whether to restore the original frame when animation finishes.
 
unsigned int getLoops () const
 Gets the times the animation is going to loop.
 
void setLoops (unsigned int loops)
 Sets the times the animation is going to loop.
 
virtual Animationclone () const override
 Returns a copy of the Object.
 
bool init ()
 Initializes a Animation.
 
bool initWithSpriteFrames (const Vector< SpriteFrame * > &arrayOfSpriteFrameNames, float delay=0.0f, unsigned int loops=1)
 Initializes a Animation with frames and a delay between frames.
 
bool initWithAnimationFrames (const Vector< AnimationFrame * > &arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops)
 Initializes a Animation with AnimationFrame.
 
- Public Member Functions inherited from Object
void retain ()
 Retains the ownership.
 
void release ()
 Releases the ownership immediately.
 
Objectautorelease ()
 Releases the ownership sometime soon automatically.
 
unsigned int getReferenceCount () const
 Returns the Object's current reference count.
 
virtual ~Object ()
 Destructor.
 
- Public Member Functions inherited from Clonable
virtual ~Clonable ()
 @js NA @lua NA
 

Static Public Member Functions

static Animationcreate ()
 Creates an animation.
 

Additional Inherited Members

- Public Attributes inherited from Object
unsigned int _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 

Detailed Description

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:

sprite->runAction(Animate::create(animation));
static Animate * create(Animation *animation)
Creates the action with an Animation and will restore the original frame when the animation is over.

Member Function Documentation

◆ create()

static Animation * create ( )
static

Creates an animation.

Since
v0.99.5

◆ addSpriteFrame()

void addSpriteFrame ( SpriteFrame * frame)

Adds a SpriteFrame to a Animation.

Parameters
frameThe frame will be added with one "delay unit".

◆ addSpriteFrameWithFile()

void addSpriteFrameWithFile ( std::string_view 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.

Parameters
filenameThe path of SpriteFrame.

◆ addSpriteFrameWithTexture()

void addSpriteFrameWithTexture ( Texture2D * pobTexture,
const Rect & rect )

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.

Parameters
pobTextureA frame with a texture.
rectThe Texture of rect.

◆ getTotalDelayUnits()

float getTotalDelayUnits ( ) const
inline

Gets the total Delay units of the Animation.

Returns
The total Delay units of the Animation.

◆ setDelayPerUnit()

void setDelayPerUnit ( float delayPerUnit)
inline

Sets the delay in seconds of the "delay unit".

Parameters
delayPerUnitThe delay in seconds of the "delay unit".

◆ getDelayPerUnit()

float getDelayPerUnit ( ) const
inline

Gets the delay in seconds of the "delay unit".

Returns
The delay in seconds of the "delay unit".

◆ getDuration()

float getDuration ( ) const

Gets the duration in seconds of the whole animation.

It is the result of totalDelayUnits * delayPerUnit.

Returns
Result of totalDelayUnits * delayPerUnit.

◆ getFrames()

const Vector< AnimationFrame * > & getFrames ( ) const
inline

Gets the array of AnimationFrames.

Returns
The array of AnimationFrames.

◆ setFrames()

void setFrames ( const Vector< AnimationFrame * > & frames)
inline

Sets the array of AnimationFrames.

Parameters
framesThe array of AnimationFrames.

◆ getRestoreOriginalFrame()

bool getRestoreOriginalFrame ( ) const
inline

Checks whether to restore the original frame when animation finishes.

Returns
Restore the original frame when animation finishes.

◆ setRestoreOriginalFrame()

void setRestoreOriginalFrame ( bool restoreOriginalFrame)
inline

Sets whether to restore the original frame when animation finishes.

Parameters
restoreOriginalFrameWhether to restore the original frame when animation finishes.

◆ getLoops()

unsigned int getLoops ( ) const
inline

Gets the times the animation is going to loop.

0 means animation is not animated. 1, animation is executed one time, ...

Returns
The times the animation is going to loop.

◆ setLoops()

void setLoops ( unsigned int loops)
inline

Sets the times the animation is going to loop.

0 means animation is not animated. 1, animation is executed one time, ...

Parameters
loopsThe times the animation is going to loop.

◆ initWithSpriteFrames()

bool initWithSpriteFrames ( const Vector< SpriteFrame * > & arrayOfSpriteFrameNames,
float delay = 0.0f,
unsigned int loops = 1 )

Initializes a Animation with frames and a delay between frames.

Since
v0.99.5

◆ initWithAnimationFrames()

bool initWithAnimationFrames ( const Vector< AnimationFrame * > & arrayOfAnimationFrameNames,
float delayPerUnit,
unsigned int loops )

Initializes a Animation with AnimationFrame.

Since
v2.0

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