CCAction类

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);
};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值