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

#include <CCArmatureAnimation.h>

Inheritance diagram for ArmatureAnimation:
ProcessBase Ref

Public Member Functions

 ArmatureAnimation ()
virtual ~ArmatureAnimation (void)
virtual bool init (Armature *armature)
 Init with a Armature. More...
 
virtual void setAnimationScale (float animationScale)
 Scale animation play speed. More...
 
virtual float getAnimationScale () const
virtual void setSpeedScale (float speedScale)
 Scale animation play speed. More...
 
virtual float getSpeedScale () const
virtual void setAnimationInternal (float animationInternal)
 The animation update speed. More...
 
virtual void play (const std::string &animationName, int durationTo=-1, int loop=-1)
 Play animation by animation name. More...
 
virtual void playByIndex (int animationIndex, int durationTo=-1, int loop=-1)
 Play animation by index, the other param is the same to play. More...
 
virtual void playWithIndex (int animationIndex, int durationTo=-1, int loop=-1)
virtual void playWithNames (const std::vector< std::string > &movementNames, int durationTo=-1, bool loop=true)
virtual void playWithIndexes (const std::vector< int > &movementIndexes, int durationTo=-1, bool loop=true)
virtual void gotoAndPlay (int frameIndex)
 Go to specified frame and play current movement. More...
 
virtual void gotoAndPause (int frameIndex)
 Go to specified frame and pause current movement. More...
 
virtual void pause ()
 Pause the Process. More...
 
virtual void resume ()
 Resume the Process. More...
 
virtual void stop ()
 Stop the Process. More...
 
ssize_t getMovementCount () const
 Get movement count. More...
 
void update (float dt)
 You should never call this function, unless you know what you do Update the Process, include current process, current frame and son on. More...
 
std::string getCurrentMovementID () const
 Get current movementID. More...
 
void setMovementEventCallFunc (cocos2d::Ref *target, SEL_MovementEventCallFunc callFunc)
 Set armature's movement event callback function To disconnect this event, just setMovementEventCallFunc(nullptr, nullptr);. More...
 
void setFrameEventCallFunc (cocos2d::Ref *target, SEL_FrameEventCallFunc callFunc)
 Set armature's frame event callback function To disconnect this event, just setFrameEventCallFunc(nullptr, nullptr);. More...
 
void setMovementEventCallFunc (std::function< void(Armature *armature, MovementEventType movementType, const std::string &movementID)> listener)
void setFrameEventCallFunc (std::function< void(Bone *bone, const std::string &frameEventName, int originFrameIndex, int currentFrameIndex)> listener)
virtual void setAnimationData (AnimationData *data)
virtual AnimationDatagetAnimationData () const
virtual RefgetUserObject ()
 Returns a user assigned Object. More...
 
virtual const RefgetUserObject () const
virtual void setUserObject (Ref *userObject)
 Returns a user assigned Object. More...
 
- Public Member Functions inherited from ProcessBase
 ProcessBase (void)
virtual ~ProcessBase (void)
virtual void play (int durationTo, int durationTween, int loop, int tweenEasing)
 Play animation by animation name. More...
 
virtual int getCurrentFrameIndex ()
virtual void setProcessScale (float processScale)
virtual float getProcessScale () const
virtual void setIsPause (bool pause)
virtual bool isPause () const
virtual void setIsComplete (bool complete)
virtual bool isComplete () const
virtual void setIsPlaying (bool playing)
virtual bool isPlaying () const
virtual float getCurrentPercent () const
virtual int getRawDuration () const
- 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 ()

Static Public Member Functions

static ArmatureAnimationcreate (Armature *armature)
 Create with a Armature. More...
 

Protected Member Functions

void updateHandler ()
 Update(float dt) will call this handler, you can handle your logic here. More...
 
void updateFrameData (float currentPercent)
 Update current key frame, and process auto stop, pause. More...
 
void frameEvent (Bone *bone, const std::string &frameEventName, int originFrameIndex, int currentFrameIndex)
 Emit a frame event. More...
 
void movementEvent (Armature *armature, MovementEventType movementType, const std::string &movementID)
 Emit a movement event. More...
 
void updateMovementList ()
bool isIgnoreFrameEvent () const
- Protected Member Functions inherited from ProcessBase
virtual void gotoFrame (int frameIndex)
- Protected Member Functions inherited from Ref
 Ref ()
 Constructor. More...
 

Protected Attributes

AnimationData_animationData
 AnimationData save all MovementDatas this animation used. More...
 
float _speedScale
 Scale the animation speed. More...
 
MovementData_movementData
Armature_armature
 MovementData save all MovementFrameDatas this animation used. More...
 
std::string _movementID
 A weak reference of armature. More...
 
int _toIndex
 Current movment's name. More...
 
cocos2d::Vector< Tween * > _tweenList
 The frame index in MovementData->m_pMovFrameDataArr, it's different from m_iFrameIndex. More...
 
bool _ignoreFrameEvent
std::queue< FrameEvent * > _frameEventQueue
std::queue< MovementEvent * > _movementEventQueue
std::vector< std::string > _movementList
bool _onMovementList
bool _movementListLoop
unsigned int _movementIndex
int _movementListDurationTo
cocos2d::Ref_userObject
SEL_MovementEventCallFunc _movementEventCallFunc
 MovementEvent CallFunc. More...
 
SEL_FrameEventCallFunc _frameEventCallFunc
 FrameEvent CallFunc. More...
 
cocos2d::Ref_movementEventTarget
cocos2d::Ref_frameEventTarget
std::function< void(Armature
*armature, MovementEventType
movementType, const
std::string &movementID)> 
_movementEventListener
std::function< void(Bone *bone,
const std::string
&frameEventName, int
originFrameIndex, int
currentFrameIndex)> 
_frameEventListener
- Protected Attributes inherited from ProcessBase
float _processScale
 Scale the process speed. More...
 
bool _isPause
 Set and get whether the aniamtion is pause. More...
 
bool _isComplete
 Set and get whether the aniamtion is complete. More...
 
bool _isPlaying
 Set and get whether the aniamtion is playing. More...
 
float _currentPercent
 Current percent this process arrived. More...
 
int _rawDuration
 The raw duration. More...
 
AnimationType _loopType
 The animation whether or not loop. More...
 
cocos2d::tweenfunc::TweenType _tweenEasing
 The tween easing effect. More...
 
float _animationInternal
 The animation update speed. More...
 
int _durationTween
 The durantion frame count will run. More...
 
float _currentFrame
 Current frame this process arrived, this frame is tween frame. More...
 
int _curFrameIndex
 Frame index it the time line. More...
 
int _nextFrameIndex
 Next frame this process need run to. More...
 
bool _isLoopBack
- Protected Attributes inherited from Ref
unsigned int _referenceCount
 count of references More...
 

Friends

class Tween

Constructor & Destructor Documentation

virtual ~ArmatureAnimation ( void  )
virtual

Member Function Documentation

static ArmatureAnimation* create ( Armature armature)
static

Create with a Armature.

Parameters
armatureThe Armature ArmatureAnimation will bind to
void frameEvent ( Bone bone,
const std::string &  frameEventName,
int  originFrameIndex,
int  currentFrameIndex 
)
protected

Emit a frame event.

virtual AnimationData*
getAnimationData
( ) const
inlinevirtual
virtual float getAnimationScale ( ) const
virtual
std::string getCurrentMovementID ( ) const

Get current movementID.

Returns
The name of current movement
ssize_t getMovementCount ( ) const

Get movement count.

virtual float getSpeedScale ( ) const
virtual
virtual Ref* getUserObject ( )
inlinevirtual

Returns a user assigned Object.

Similar to userData, but instead of holding a void* it holds an object

Returns
A user assigned Object
virtual const Ref* getUserObject ( ) const
inlinevirtual
virtual void gotoAndPause ( int  frameIndex)
virtual

Go to specified frame and pause current movement.

virtual void gotoAndPlay ( int  frameIndex)
virtual

Go to specified frame and play current movement.

You need first switch to the movement you want to play, then call this function.

example : playByIndex(0); gotoAndPlay(0); playByIndex(1); gotoAndPlay(0); gotoAndPlay(15);

virtual bool init ( Armature armature)
virtual

Init with a Armature.

Parameters
armatureThe Armature ArmatureAnimation will bind to
bool isIgnoreFrameEvent ( ) const
inlineprotected
void movementEvent ( Armature armature,
MovementEventType  movementType,
const std::string &  movementID 
)
protected

Emit a movement event.

virtual void pause ( )
virtual

Pause the Process.

Reimplemented from ProcessBase.

virtual void play ( const std::string &  animationName,
int  durationTo = -1,
int  loop = -1 
)
virtual

Play animation by animation name.

Parameters
animationNameThe animation name you want to play
durationToThe frames between two animation changing-over. It's meaning is changing to this animation need how many frames

-1 : use the value from MovementData get from flash design panel

Parameters
loopWhether the animation is loop
    loop < 0 : use the value from MovementData get from flash design panel
    loop = 0 : this animation is not loop
    loop > 0 : this animation is loop
virtual void playByIndex ( int  animationIndex,
int  durationTo = -1,
int  loop = -1 
)
virtual

Play animation by index, the other param is the same to play.

Deprecated:
, please use playWithIndex
Parameters
animationIndexthe animation index you want to play
virtual void playWithIndex ( int  animationIndex,
int  durationTo = -1,
int  loop = -1 
)
virtual
virtual void playWithIndexes ( const std::vector< int > &  movementIndexes,
int  durationTo = -1,
bool  loop = true 
)
virtual
virtual void playWithNames ( const std::vector< std::string > &  movementNames,
int  durationTo = -1,
bool  loop = true 
)
virtual
virtual void resume ( )
virtual

Resume the Process.

Reimplemented from ProcessBase.

virtual void setAnimationData ( AnimationData data)
inlinevirtual
virtual void setAnimationInternal ( float  animationInternal)
inlinevirtual

The animation update speed.

virtual void setAnimationScale ( float  animationScale)
virtual

Scale animation play speed.

This method is deprecated, please use setSpeedScale.

Parameters
animationScaleScale value
void setFrameEventCallFunc ( cocos2d::Ref target,
SEL_FrameEventCallFunc  callFunc 
)

Set armature's frame event callback function To disconnect this event, just setFrameEventCallFunc(nullptr, nullptr);.

void setFrameEventCallFunc ( std::function< void(Bone *bone, const std::string &frameEventName, int originFrameIndex, int currentFrameIndex)>  listener)
void setMovementEventCallFunc ( cocos2d::Ref target,
SEL_MovementEventCallFunc  callFunc 
)

Set armature's movement event callback function To disconnect this event, just setMovementEventCallFunc(nullptr, nullptr);.

void setMovementEventCallFunc ( std::function< void(Armature *armature, MovementEventType movementType, const std::string &movementID)>  listener)
virtual void setSpeedScale ( float  speedScale)
virtual

Scale animation play speed.

Parameters
animationScaleScale value
virtual void setUserObject ( Ref userObject)
virtual

Returns a user assigned Object.

Similar to UserData, but instead of holding a void* it holds an object. The UserObject will be retained once in this method, and the previous UserObject (if existed) will be relese. The UserObject will be released in Node's destructure.

Parameters
userObjectA user assigned Object
virtual void stop ( )
virtual

Stop the Process.

Reimplemented from ProcessBase.

void update ( float  dt)
virtual

You should never call this function, unless you know what you do Update the Process, include current process, current frame and son on.

Parameters
Theduration since last update

Reimplemented from ProcessBase.

void updateFrameData ( float  currentPercent)
protected

Update current key frame, and process auto stop, pause.

void updateHandler ( )
protectedvirtual

Update(float dt) will call this handler, you can handle your logic here.

Reimplemented from ProcessBase.

void updateMovementList ( )
protected

Friends And Related Function Documentation

friend class Tween
friend

Member Data Documentation

AnimationData* _animationData
protected

AnimationData save all MovementDatas this animation used.

Armature* _armature
protected

MovementData save all MovementFrameDatas this animation used.

SEL_FrameEventCallFunc
_frameEventCallFunc
protected

FrameEvent CallFunc.

Parameters
Bone*,aBone
constchar*, the name of this frame event
int,originframe index
int,currentframe index, animation may be delayed
std::function<void(Bone *bone,
const std::string&
frameEventName, int
originFrameIndex, int
currentFrameIndex)>
_frameEventListener
protected
std::queue<FrameEvent*>
_frameEventQueue
protected
cocos2d::Ref* _frameEventTarget
protected
bool _ignoreFrameEvent
protected
MovementData* _movementData
protected
SEL_MovementEventCallFunc
_movementEventCallFunc
protected

MovementEvent CallFunc.

Parameters
Armature*a Armature
MovementEventType,EventType, like START, COMPLETE.
constchar*, Movement ID, also called Movement Name
std::function<void(Armature
*armature, MovementEventType
movementType, const
std::string& movementID)>
_movementEventListener
protected
std::queue<MovementEvent*>
_movementEventQueue
protected
cocos2d::Ref* _movementEventTarget
protected
std::string _movementID
protected

A weak reference of armature.

unsigned int _movementIndex
protected
std::vector<std::string>
_movementList
protected
int _movementListDurationTo
protected
bool _movementListLoop
protected
bool _onMovementList
protected
float _speedScale
protected

Scale the animation speed.

int _toIndex
protected

Current movment's name.

cocos2d::Vector<Tween*> _tweenList
protected

The frame index in MovementData->m_pMovFrameDataArr, it's different from m_iFrameIndex.

cocos2d::Ref* _userObject
protected

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