Cocos2d-x结构学习(十五)CCJumpBy、CCRotateBy、CCSpawn、CCSpeed

前端之家收集整理的这篇文章主要介绍了Cocos2d-x结构学习(十五)CCJumpBy、CCRotateBy、CCSpawn、CCSpeed前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、CCJumpBy:跳跃,继承自CCActionInterval

class CC_DLL CCJumpBy : public CCActionInterval
{
public:
    bool initWithDuration(float duration,const CCPoint& position,float height,unsigned int jumps);
    virtual CCObject* copyWithZone(CCZone* pZone);
    virtual void startWithTarget(CCNode *pTarget);
    virtual void update(float time);
    virtual CCActionInterval* reverse(void);

public:
    static CCJumpBy* create(float duration,unsigned int jumps);
protected:
    CCPoint         m_startPosition;
    CCPoint         m_delta;
    float           m_height;
    unsigned int    m_nJumps;
    CCPoint         m_prevIoUsPos;
};
2、CCRotateBy:旋转,继承自CCActionInterval
class CC_DLL CCRotateBy : public CCActionInterval
{
public:
    static CCRotateBy* create(float fDuration,float fDeltaAngle);
    bool initWithDuration(float fDuration,float fDeltaAngle);
    static CCRotateBy* create(float fDuration,float fDeltaAngleX,float fDeltaAngleY);
    bool initWithDuration(float fDuration,float fDeltaAngleY);

    virtual CCObject* copyWithZone(CCZone* pZone);
    virtual void startWithTarget(CCNode *pTarget);
    virtual void update(float time);
    virtual CCActionInterval* reverse(void);
    
protected:
    float m_fAngleX;
    float m_fStartAngleX;
    float m_fAngleY;
    float m_fStartAngleY;
};
3、CCSpawn:继承自CCActionInterval
class CC_DLL CCSpawn : public CCActionInterval
{
public:
    ~CCSpawn(void);
    bool initWithTwoActions(CCFiniteTimeAction *pAction1,CCFiniteTimeAction *pAction2);

    virtual CCObject* copyWithZone(CCZone* pZone);
    virtual void startWithTarget(CCNode *pTarget);
    virtual void stop(void);
    virtual void update(float time);
    virtual CCActionInterval* reverse(void);

public:
    static CCSpawn* create(CCFiniteTimeAction *pAction1,...);
    static CCSpawn* createWithVariableList(CCFiniteTimeAction *pAction1,va_list args);
    static CCSpawn* create(CCArray *arrayOfActions);
    static CCSpawn* createWithTwoActions(CCFiniteTimeAction *pAction1,CCFiniteTimeAction *pAction2);

protected:
    CCFiniteTimeAction *m_pOne;
    CCFiniteTimeAction *m_pTwo;
};
4、CCSpeed:速度,继承自CCAction
class CC_DLL CCSpeed : public CCAction
{
public:
    CCSpeed()
        : m_fSpeed(0.0),m_pInnerAction(NULL)
    {}
    virtual ~CCSpeed(void);

    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()
    {
        return m_pInnerAction;
    }

public:
    static CCSpeed* create(CCActionInterval* pAction,float fSpeed);
protected:
    float m_fSpeed;
    CCActionInterval *m_pInnerAction;
};
原文链接:https://www.f2er.com/cocos2dx/343764.html

猜你在找的Cocos2d-x相关文章