class CC_DLL CCAction : public CCObject
{
public:
CCAction(void);
virtual ~CCAction(void);
const char* description();
// 用于动作拷贝
virtual CCObject* copyWithZone(CCZone *pZone);
// 查询动作是否已做完
virtual bool isDone(void);
// 动作调用之前调用
virtual void startWithTarget(CCNode *pTarget);
// 动作完成后调用
virtual void stop(void);
// 每帧都会调用
virtual void step(float dt);
// 每帧调用来更新动作
virtual void update(float time);
// 获取Target节点
inline CCNode* getTarget(void) { return m_pTarget; }
inline void setTarget(CCNode *pTarget) { m_pTarget = pTarget; }
inline CCNode* getOriginalTarget(void) { return m_pOriginalTarget; }
inline void setOriginalTarget(CCNode *pOriginalTarget) { m_pOriginalTarget = pOriginalTarget; }
// 设置、获取tag值
inline int getTag(void) { return m_nTag; }
inline void setTag(int nTag) { m_nTag = nTag; }
// 创建动作对象
static CCAction* create();
};
// 有限时间的动作对象
class CC_DLL CCFiniteTimeAction : public CCAction
{
public:
CCFiniteTimeAction();
virtual ~CCFiniteTimeAction();
// 获取、设置动作的持续时间
inline float getDuration(void) { return m_fDuration; }
inline void setDuration(float duration) { m_fDuration = duration; }
// 取该动作对象的逆序
virtual CCFiniteTimeAction* reverse(void);
};
class CCActionInterval;
class CCRepeatForever;
// 改变动作对象的速度,Useful to simulate 'slow motion' or 'fast forward' effect.
class CC_DLL CCSpeed : public CCAction
{
public:
CCSpeed();
virtual ~CCSpeed(void);
// 设置、获取速度,alter the speed of the inner function in runtime
inline float getSpeed(void) { return m_fSpeed; }
inline void setSpeed(float fSpeed) { m_fSpeed = fSpeed; }
// 初始化动作对象
bool initWithAction(CCActionInterval *pAction, float fSpeed);
// 继承父类函数
virtual CCObject* copyWithZone(CCZone *pZone);
virtual void startWithTarget(CCNode* pTarget);
virtual void stop();
virtual void step(float dt);
virtual bool isDone(void);
virtual CCActionInterval* reverse(void);
// 设置内部动作对象
void setInnerAction(CCActionInterval *pAction);
inline CCActionInterval* getInnerAction();
// 创建该动作
static CCSpeed* create(CCActionInterval* pAction, float fSpeed);
protected:
float m_fSpeed;
CCActionInterval *m_pInnerAction;
};
// 跟随节点的动作对象
class CC_DLL CCFollow : public CCAction
{
public:
CCFollow();
virtual ~CCFollow(void);
// 开启、关闭边界
inline bool isBoundarySet(void) { return m_bBoundarySet; }
inline void setBoudarySet(bool bValue) { m_bBoundarySet = bValue; }
// 初始化对象
bool initWithTarget(CCNode *pFollowedNode, const CCRect& rect = CCRectZero);
// 继承父类函数
virtual CCObject* copyWithZone(CCZone *pZone);
virtual void step(float dt);
virtual bool isDone(void);
virtual void stop(void);
// 创建跟随动作对象
static CCFollow* create(CCNode *pFollowedNode, const CCRect& rect = CCRectZero);
};
CCAction类
最新推荐文章于 2019-05-03 20:52:16 发布