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

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

#include <CCAnimation.h>

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

Public Member Functions

 CCAnimation ()
 ctor More...
 
 ~CCAnimation (void)
 NA NA. More...
 
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 ()
 NA. More...
 
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)
 NA NA. More...
 
virtual float getTotalDelayUnits (void)
 
virtual float getDelayPerUnit (void)
 
virtual void setDelayPerUnit (float var)
 
virtual float getDuration (void)
 
virtual CCArraygetFrames (void)
 
virtual void setFrames (CCArray *var)
 
virtual bool getRestoreOriginalFrame (void)
 
virtual void setRestoreOriginalFrame (bool var)
 
virtual unsigned int getLoops (void)
 
virtual void setLoops (unsigned int var)
 
- 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)
 
virtual CCObjectcopyWithZone (CCZone *pZone)
 

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)
 
- Static Public Member Functions inherited from CCObject
static CCObjectcreateWithCoder (DS_Dictionary *)
 

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
 duration in seconds of the whole animation. 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
 how many times the animation is going to loop. More...
 
- 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

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

ctor

◆ ~CCAnimation()

~CCAnimation ( void  )

NA NA.

Member Function Documentation

◆ addSpriteFrame()

void addSpriteFrame ( CCSpriteFrame pFrame)

Adds a CCSpriteFrame to a CCAnimation.

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

◆ addSpriteFrameWithFileName()

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

◆ addSpriteFrameWithTexture()

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.

◆ copyWithZone()

virtual CCObject * copyWithZone ( CCZone pZone)
virtual

NA NA.

Reimplemented from CCCopying.

◆ create() [1/3]

static CCAnimation * create ( CCArray arrayOfAnimationFrameNames,
float  delayPerUnit 
)
inlinestatic

◆ create() [2/3]

static CCAnimation * create ( CCArray arrayOfAnimationFrameNames,
float  delayPerUnit,
unsigned int  loops 
)
static

◆ create() [3/3]

static CCAnimation * create ( void  )
static

Creates an animation.

Since
v0.99.5

◆ createWithSpriteFrames()

static CCAnimation * createWithSpriteFrames ( CCArray arrayOfSpriteFrameNames,
float  delay = 0.0f 
)
static

◆ getDelayPerUnit()

virtual float getDelayPerUnit ( void  )
virtual

◆ getDuration()

virtual float getDuration ( void  )
virtual

◆ getFrames()

virtual CCArray * getFrames ( void  )
virtual

◆ getLoops()

virtual unsigned int getLoops ( void  )
virtual

◆ getRestoreOriginalFrame()

virtual bool getRestoreOriginalFrame ( void  )
virtual

◆ getTotalDelayUnits()

virtual float getTotalDelayUnits ( void  )
virtual

◆ init()

bool init ( )

NA.

◆ initWithAnimationFrames()

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

Initializes a CCAnimation with CCAnimationFrame.

Since
v2.0 NA

◆ initWithSpriteFrames()

bool initWithSpriteFrames ( CCArray pFrames,
float  delay = 0.0f 
)

Initializes a CCAnimation with frames and a delay between frames.

Since
v0.99.5 NA

◆ setDelayPerUnit()

virtual void setDelayPerUnit ( float  var)
virtual

◆ setFrames()

virtual void setFrames ( CCArray var)
virtual

◆ setLoops()

virtual void setLoops ( unsigned int  var)
virtual

◆ setRestoreOriginalFrame()

virtual void setRestoreOriginalFrame ( bool  var)
virtual

Member Data Documentation

◆ m_bRestoreOriginalFrame

bool m_bRestoreOriginalFrame
protected

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

◆ m_fDelayPerUnit

float m_fDelayPerUnit
protected

Delay in seconds of the "delay unit".

◆ m_fDuration

float m_fDuration
protected

duration in seconds of the whole animation.

It is the result of totalDelayUnits * delayPerUnit

◆ m_fTotalDelayUnits

float m_fTotalDelayUnits
protected

total Delay units of the CCAnimation.

◆ m_pFrames

CCArray* m_pFrames
protected

array of CCAnimationFrames

◆ m_uLoops

unsigned int m_uLoops
protected

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: