cocos2d-x节点(CCActionGrid.h)API

本文来自http://blog.csdn.net/runaying ,引用必须注明出处!

cocos2d-x节点(CCActionGrid.h)API

温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记

各种网格 action 效果

///cocos2d-x-3.0alpha0/cocos2dx/actions
//各种网格 action 效果

#ifndef __ACTION_CCGRID_ACTION_H__
#define __ACTION_CCGRID_ACTION_H__

#include "CCActionInterval.h"
#include "CCActionInstant.h"

NS_CC_BEGIN

class GridBase;

/**
 * @addtogroup actions
 * @{
 */

/** @brief Base class for Grid actions */
class CC_DLL GridAction : public ActionInterval
{
public:
    /** 使用 size 、 duration 创建一个 action*/
    bool initWithDuration(float duration, const Size& gridSize);

    /** returns the grid */
    virtual GridBase* getGrid();

    // overrides
	virtual GridAction * clone() const override = 0;
    virtual GridAction* reverse() const override;
    virtual void startWithTarget(Node *target) override;

protected:
    Size _gridSize;
};

/** 
 @brief Base class for Grid3D actions.
 Grid3D actions 可以修改一个 non-tiled(非瓷砖) grid.
 */
class CC_DLL Grid3DAction : public GridAction
{
public:

    /** returns the grid */
    virtual GridBase* getGrid(void);
    /** returns 顶点在网格中的位置
     * @js NA
     * @lua NA
     */
    Vertex3F getVertex(const Point& position) const;

    /** @过时不再需要建议使用新的 API 建议使用 getVertex() 代替 
     * @js NA
     * @lua NA
     */
    CC_DEPRECATED_ATTRIBUTE inline Vertex3F vertex(const Point& position) { return getVertex(position); }

    /** returns  non-transformed(未转化的)顶点在网格中的位置
     * @js NA
     * @lua NA
     */
    Vertex3F getOriginalVertex(const Point& position) const;

    /** @过时不再需要建议使用新的 API getOriginalVertex() 代替 
     * @js NA
     * @lua NA
     */
    CC_DEPRECATED_ATTRIBUTE inline Vertex3F originalVertex(const Point& position) { return getOriginalVertex(position); }

    /** 网格中的特定位置设置一个新的顶点
     * @js NA
     * @lua NA
     */
    void setVertex(const Point& position, const Vertex3F& vertex);

    // Overrides
	virtual Grid3DAction * clone() const override = 0;
};

/** @brief Base class for TiledGrid3D actions */
class CC_DLL TiledGrid3DAction : public GridAction
{
public:
    /** 使用 size 、 duration 创建一个 action 
     * @js NA
     * @lua NA
     */
    static TiledGrid3DAction* create(float duration, const Size& gridSize);

    /** returns grid (网格) 中特定位置的瓷砖(tile)
     * @js NA
     * @lua NA
     */
    Quad3 getTile(const Point& position) const;

    /** @过时不再需要建议使用新的 API ,可以使用 getTile() 代替 
     * @js NA
     * @lua NA
     */
    CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Point& position) { return getTile(position); }

    /** returns grid (网格) 中特定位置为发生转换的瓷砖(tile)
     * @js NA
     * @lua NA
     */
    Quad3 getOriginalTile(const Point& position) const;

    /** @过时不再需要建议使用新的 API ,可以使用 getOriginalTile() 代替 
     * @js NA
     * @lua NA
     */
    CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Point& position) { return getOriginalTile(position); }

    /** sets grid (网格) 中特定位置的瓷砖(tile) 
     * @js NA
     * @lua NA
     */
    void setTile(const Point& position, const Quad3& coords);

    /** returns the grid */
    virtual GridBase* getGrid(void);

    // Override
    virtual TiledGrid3DAction * clone() const override = 0;
};

/** @brief AccelDeccelAmplitude(加速减速幅度) action */
class CC_DLL AccelDeccelAmplitude : public ActionInterval
{
public:
    /** 使用 具有振幅属性的内部 action 、duration 创建一个 action   */
    static AccelDeccelAmplitude* create(Action *pAction, float duration);
    /**
     * @js NA
     * @lua NA
     */
    virtual ~AccelDeccelAmplitude(void);
    /** 使用 具有振幅属性的内部 action 、duration 初始化一个 action  */
    bool initWithAction(Action *pAction, float duration);

	/** returns 一个动作的副本 */
	virtual AccelDeccelAmplitude* clone() const;
	/** returns 一个动作的逆顺序 */
	virtual AccelDeccelAmplitude* reverse() const;

    /** get 振幅速率 */
    inline float getRate(void) const { return _rate; }
    /** set 振幅速率 */
    inline void setRate(float fRate) { _rate = fRate; }

    // Overrides
    virtual void startWithTarget(Node *target) override;
    virtual void update(float time) override;

protected:
    float _rate;
    ActionInterval *_other;
};

/** @brief AccelAmplitude(加速幅度) action */
class CC_DLL AccelAmplitude : public ActionInterval
{
public:
    /** 使用 具有振幅属性的内部 action 、duration 创建一个 action  */
    static AccelAmplitude* create(Action *pAction, float duration);
    /**
     * @js NA
     * @lua NA
     */
    virtual ~AccelAmplitude(void);

    /** 使用 具有振幅属性的内部 action 、duration 初始化一个 action */
    bool initWithAction(Action *pAction, float duration);

    /** get 振幅速率 */
    inline float getRate(void) const { return _rate; }
    /** set 振幅速率 */
    inline void setRate(float fRate) { _rate = fRate; }

    // Overrides
    virtual void startWithTarget(Node *target) override;
    virtual void update(float time) override;
	virtual AccelAmplitude* clone() const override;
	virtual AccelAmplitude* reverse() const override;

protected:
    float _rate;
    ActionInterval *_other;
};

/** @brief DeccelAmplitude action */
class CC_DLL DeccelAmplitude : public ActionInterval
{
public:
    /** 使用 具有振幅属性的内部 action 、duration 创建一个 action  */
    static DeccelAmplitude* create(Action *pAction, float duration);
    /**
     * @js NA
     * @lua NA
     */
    virtual ~DeccelAmplitude();
    /** 使用 具有振幅属性的内部 action 、duration 初始化一个 action */
    bool initWithAction(Action *pAction, float duration);

    /** get 振幅速率 */
    inline float getRate(void) const { return _rate; }
    /** set 振幅速率 */
    inline void setRate(float fRate) { _rate = fRate; }

    // overrides
    virtual void startWithTarget(Node *target) override;
    virtual void update(float time) override;
	virtual DeccelAmplitude* clone() const;
	virtual DeccelAmplitude* reverse() const;

protected:
    float _rate;
    ActionInterval *_other;
};

/** @brief StopGrid action.
 @warning 如果另一个 grid action 激活了,就不要再调用这个方法了
如果你要移除 grid 效果可以调用他. Example:
 Sequence::actions(Lens::action(...), StopGrid::action(...), NULL);
 */
class CC_DLL StopGrid : public ActionInstant
{
public:
    /** Allocates and initializes the action */
    static StopGrid* create(void);

    // Overrides
    virtual void startWithTarget(Node *target) override;
	virtual StopGrid* clone() const override;
	virtual StopGrid* reverse() const override;
};

/** @brief ReuseGrid action */
class CC_DLL ReuseGrid : public ActionInstant
{
public:
    /** 使用 当前 grid(网格)被重用的次数 创建一个 action */
    static ReuseGrid* create(int times);

    /** 使用 当前 grid(网格)被重用的次数 初始化
     一个 action */
    bool initWithTimes(int times);

    // Override
    virtual void startWithTarget(Node *target) override;
	virtual ReuseGrid* clone() const override;
	virtual ReuseGrid* reverse() const override;

protected:
    int _times;
};

// end of actions group
/// @}

NS_CC_END

#endif // __ACTION_CCGRID_ACTION_H__


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值