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

A CCAnimation object is used to perform animations on the CCSprite objects. More...

#include <CCAnimation.h>

Inheritance diagram for CCAnimation:
CCObject CCCopying

Public Member Functions

 CCAnimation ()
 ~CCAnimation (void)
void addSpriteFrame (CCSpriteFrame *pFrame)
 Adds a CCSpriteFrame to a CCAnimation. More...
 
void addSpriteFrameWithFileName (const char *pszFileName)
 Adds a frame with an image filename. More...
 
void addSpriteFrameWithTexture (CCTexture2D *pobTexture, const CCRect &rect)
 Adds a frame with a texture and a rect. More...
 
bool init ()
bool initWithSpriteFrames (CCArray *pFrames, float delay=0.0f)
 Initializes a CCAnimation with frames and a delay between frames. More...
 
bool initWithAnimationFrames (CCArray *arrayOfAnimationFrames, float delayPerUnit, unsigned int loops)
 Initializes a CCAnimation with CCAnimationFrame. More...
 
virtual CCObjectcopyWithZone (CCZone *pZone)
virtual float getTotalDelayUnits (void)
 getTotalDelayUnits More...
 
virtual float getDuration (void)
 getDuration More...
 
virtual CCArraygetFrames (void)
 getFrames More...
 
virtual void setFrames (CCArray *var)
 setFrames 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)

Static Public Member Functions

static CCAnimationcreate (void)
 Creates an animation. More...
 
static CCAnimationcreateWithSpriteFrames (CCArray *arrayOfSpriteFrameNames, float delay=0.0f)
static CCAnimationcreate (CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops)
static CCAnimationcreate (CCArray *arrayOfAnimationFrameNames, float delayPerUnit)

Protected Attributes

float m_fTotalDelayUnits
 total Delay units of the CCAnimation. More...
 
float m_fDelayPerUnit
 Delay in seconds of the "delay unit". More...
 
float m_fDuration
 getDelayPerUnit More...
 
CCArraym_pFrames
 array of CCAnimationFrames More...
 
bool m_bRestoreOriginalFrame
 whether or not it shall restore the original frame when the animation finishes More...
 
unsigned int m_uLoops
 getRestoreOriginalFrame More...
 
- 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

A CCAnimation object is used to perform animations on the CCSprite objects.

The CCAnimation object contains CCAnimationFrame objects, and a possible delay between the frames. You can animate a CCAnimation object by using the CCAnimate action. Example:

[sprite runAction:[CCAnimate actionWithAnimation:animation]];

Constructor & Destructor Documentation

~CCAnimation ( void  )

Member Function Documentation

void addSpriteFrame ( CCSpriteFrame pFrame)

Adds a CCSpriteFrame to a CCAnimation.

The frame will be added with one "delay unit".

void addSpriteFrameWithFileName ( const char *  pszFileName)

Adds a frame with an image filename.

Internally it will create a CCSpriteFrame 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.

void addSpriteFrameWithTexture ( CCTexture2D pobTexture,
const CCRect rect 
)

Adds a frame with a texture and a rect.

Internally it will create a CCSpriteFrame 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.

virtual CCObject* copyWithZone ( CCZone pZone)
virtual

Reimplemented from CCCopying.

static CCAnimation* create ( void  )
static

Creates an animation.

Since
v0.99.5
static CCAnimation* create ( CCArray arrayOfAnimationFrameNames,
float  delayPerUnit,
unsigned int  loops 
)
static
static CCAnimation* create ( CCArray arrayOfAnimationFrameNames,
float  delayPerUnit 
)
inlinestatic
static CCAnimation*
createWithSpriteFrames
( CCArray arrayOfSpriteFrameNames,
float  delay = 0.0f 
)
static
virtual float getDuration ( void  )
virtual

getDuration

virtual CCArray* getFrames ( void  )
virtual

getFrames

virtual float getTotalDelayUnits ( void  )
virtual

getTotalDelayUnits

bool init ( )
bool initWithAnimationFrames ( CCArray arrayOfAnimationFrames,
float  delayPerUnit,
unsigned int  loops 
)

Initializes a CCAnimation with CCAnimationFrame.

Since
v2.0
bool initWithSpriteFrames ( CCArray pFrames,
float  delay = 0.0f 
)

Initializes a CCAnimation with frames and a delay between frames.

Since
v0.99.5
virtual void setFrames ( CCArray var)
virtual

setFrames

Member Data Documentation

bool m_bRestoreOriginalFrame
protected

whether or not it shall restore the original frame when the animation finishes

float m_fDelayPerUnit
protected

Delay in seconds of the "delay unit".

float m_fDuration
protected

getDelayPerUnit

setDelayPerUnit duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit

float m_fTotalDelayUnits
protected

total Delay units of the CCAnimation.

CCArray* m_pFrames
protected

array of CCAnimationFrames

unsigned int m_uLoops
protected

getRestoreOriginalFrame

setRestoreOriginalFrame how many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ...


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