1、CCMoveBy:移动动作,继承自CCActionInterval
class CC_DLL CCMoveBy : public CCActionInterval { public: bool initWithDuration(float duration,const CCPoint& deltaPosition); //初始化序列 virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); //开始目标 virtual CCActionInterval* reverse(void); virtual void update(float time); //更新 public: static CCMoveBy* create(float duration,const CCPoint& deltaPosition); protected: CCPoint m_positionDelta; CCPoint m_startPosition; CCPoint m_prevIoUsPosition; };2、CCActionInterval:动作间隔类,继承自CCFiniteTimeAction
class CC_DLL CCActionInterval : public CCFiniteTimeAction { public: inline float getElapsed(void) { return m_elapsed; } //获取从动作开始到目前已逝去的秒 bool initWithDuration(float d); //初始化动作 virtual bool isDone(void); //判断动作是否运行完成 virtual CCObject* copyWithZone(CCZone* pZone); virtual void step(float dt); virtual void startWithTarget(CCNode *pTarget); /** returns a reversed action */ virtual CCActionInterval* reverse(void); public: static CCActionInterval* create(float d); public: void setAmplitudeRate(float amp); //设置和获得扩展 float getAmplitudeRate(void); protected: float m_elapsed; bool m_bFirstTick; };3、CCFiniteTimeAction:有限时间动作,继承自CCAction
class CC_DLL CCFiniteTimeAction : public CCAction { public: CCFiniteTimeAction() : m_fDuration(0) {} virtual ~CCFiniteTimeAction(){} inline float getDuration(void) { return m_fDuration; } //设置和获得持续时间 inline void setDuration(float duration) { m_fDuration = duration; } virtual CCFiniteTimeAction* reverse(void); //返回一个倒退序列 protected: float m_fDuration; };4、CCCallFunc:动作回调函数处理类,继承自CCActionInstant
class CC_DLL CCCallFunc : public CCActionInstant { public: CCCallFunc() : m_pSelectorTarget(NULL),m_nScriptHandler(0),m_pCallFunc(NULL) { } virtual ~CCCallFunc(); static CCCallFunc * create(CCObject* pSelectorTarget,SEL_CallFunc selector); //创建和初始化相关函数 static CCCallFunc * create(int nHandler); virtual bool initWithTarget(CCObject* pSelectorTarget);
virtual void execute(); //执行 virtual void update(float time); //更新 CCObject * copyWithZone(CCZone *pZone);
inline CCObject* getTargetCallback() //设置和获得回调对象 { return m_pSelectorTarget; } inline void setTargetCallback(CCObject* pSel) { if (pSel != m_pSelectorTarget) { CC_SAFE_RETAIN(pSel); CC_SAFE_RELEASE(m_pSelectorTarget); m_pSelectorTarget = pSel; } } inline int getScriptHandler() { return m_nScriptHandler; }; //得到脚本句柄 protected: CCObject* m_pSelectorTarget; int m_nScriptHandler; union { SEL_CallFunc m_pCallFunc; SEL_CallFuncN m_pCallFuncN; SEL_CallFuncND m_pCallFuncND; SEL_CallFuncO m_pCallFuncO; }; };5、CC_SAFE_RETAIN:这个宏有意思,搞个一次循环
#define CC_SAFE_RETAIN(p) do { if(p) { (p)->retain(); } } while(0)6、CCActionInstant:立即动作类,继承自CCFiniteTimeAction,比较简陋
class CC_DLL CCActionInstant : public CCFiniteTimeAction { public: CCActionInstant(); virtual ~CCActionInstant(){} virtual CCObject* copyWithZone(CCZone *pZone); virtual bool isDone(void); virtual void step(float dt); virtual void update(float time); virtual CCFiniteTimeAction * reverse(void); };原文链接:https://www.f2er.com/cocos2dx/343794.html