cocos2d-x节点(CCActionCatmullRom.h)API
2013-12-08 09:28
513 查看
本文来自http://blog.csdn.net/runaying ,引用必须注明出处!
CatmullRom(卡特莫尔罗)action
cocos2d-x节点(CCActionCatmullRom.h)API
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记CatmullRom(卡特莫尔罗)action
///cocos2d-x-3.0alpha0/cocos2dx/actions //CatmullRom(卡特莫尔罗)action /* * * * Original code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So * * Adapted to cocos2d-x by Vit Valentin * * Adapted from cocos2d-x to cocos2d-iphone by Ricardo Quesada */ #ifndef __CCACTION_CATMULLROM_H__ #define __CCACTION_CATMULLROM_H__ #include <vector> #include "CCActionInterval.h" #include "base_nodes/CCNode.h" #include "cocoa/CCGeometry.h" NS_CC_BEGIN; /** * @addtogroup actions * @{ */ /** 一个包含控制点的 Array Used by CardinalSplineTo and (By) and CatmullRomTo (and By) actions. @ingroup Actions //圈内动作 */ class CC_DLL PointArray : public Object, public Clonable { public: /** 创建并初始化一个点阵列(array)的容量 * @js NA */ static PointArray* create(unsigned int capacity); /** * @js NA * @lua NA */ virtual ~PointArray(); /** * @js NA * @lua NA */ PointArray(); /** 初始化 Catmull Rom 配置的提示容量 * @js NA */ bool initWithCapacity(unsigned int capacity); /** 附加一个控制点 * @js NA */ void addControlPoint(Point controlPoint); /** 在索引位置插入一个 controlPoint * @js NA */ void insertControlPoint(Point &controlPoint, unsigned int index); /** 替换索引位置存在的 controlPoint * @js NA */ void replaceControlPoint(Point &controlPoint, unsigned int index); /** 获取制定索引位置的 controlPoint 的值 * @js NA */ Point getControlPointAtIndex(unsigned int index); /** 删除给定索引位置的控制点 * @js NA */ void removeControlPointAtIndex(unsigned int index); /** returns 控制点对象的数目 * @js NA */ unsigned int count() const; /** returns 一个逆顺序的点阵(array)列副本,用户是负责释放这个副本 * @js NA */ PointArray* reverse() const; /** 逆转当前点阵列(array),而不会生成一个新的点阵列(array) * @js NA */ void reverseInline(); /** * @js NA * @lua NA */ virtual PointArray* clone() const; /** * @js NA */ const std::vector<Point*>* getControlPoints() const; /** * @js NA */ void setControlPoints(std::vector<Point*> *controlPoints); private: /** 一个包含控制点的 Array */ std::vector<Point*> *_controlPoints; }; /** Cardinal Spline path. //三次Hermite样条/基数样条路径 http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline @ingroup Actions */ class CC_DLL CardinalSplineTo : public ActionInterval { public: /** 使用 points(点阵列)、 tension(张力)、duration创建一个 action * @code * 当这个函数绑定到 js or lua,输入参数会改变 * in js: var create(var t,var table) * in lua: lcaol create(local t, local table) * @endcode */ static CardinalSplineTo* create(float duration, PointArray* points, float tension); /** * @js NA * @lua NA */ virtual ~CardinalSplineTo(); /** * @js NA * @lua NA */ CardinalSplineTo(); /** 使用点阵列(array)和持续时间,初始化一个 action */ bool initWithDuration(float duration, PointArray* points, float tension); virtual void updatePosition(Point &newPos); inline PointArray* getPoints() { return _points; } /** * @js NA * @lua NA */ inline void setPoints(PointArray* points) { CC_SAFE_RETAIN(points); CC_SAFE_RELEASE(_points); _points = points; } // Overrides virtual CardinalSplineTo *clone() const override; virtual CardinalSplineTo* reverse() const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: /** 控制点阵列 */ PointArray *_points; float _deltaT; float _tension; Point _previousPosition; Point _accumulatedDiff; }; /** Cardinal Spline path. //三次Hermite样条/基数样条路径 http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline @ingroup Actions */ class CC_DLL CardinalSplineBy : public CardinalSplineTo { public: /** 使用 points(点阵列)、 tension(张力)、duration创建一个 action * @code * 当这个函数绑定到 js or lua,输入参数会改变 * in js: var create(var t,var table) * in lua: lcaol create(local t, local table) * @endcode */ static CardinalSplineBy* create(float duration, PointArray* points, float tension); CardinalSplineBy(); // Overrides virtual void startWithTarget(Node *target) override; virtual void updatePosition(Point &newPos) override; virtual CardinalSplineBy *clone() const override; virtual CardinalSplineBy* reverse() const override; protected: Point _startPosition; }; /** 使用 CatmullRom curve(卡特莫尔罗曲线)把目标移动到目标点 Catmull Rom (卡特莫尔罗)是一个 tension(张力)是 0.5 的 Cardinal Spline (基数样条) http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline @ingroup Actions */ class CC_DLL CatmullRomTo : public CardinalSplineTo { public: /** 使用 points、 tension(张力)创建一个 action * @code * 当这个函数绑定到 js or lua,输入参数会改变 * in js: var create(var dt,var table) * in lua: lcaol create(local dt, local table) * @endcode */ static CatmullRomTo* create(float dt, PointArray* points); /** 使用 points(点阵列)、duration创建一个 action */ bool initWithDuration(float dt, PointArray* points); // Override virtual CatmullRomTo *clone() const override; virtual CatmullRomTo *reverse() const override; }; /** 使用 CatmullRom curve(卡特莫尔罗曲线)把目标移动 Catmull Rom (卡特莫尔罗)是一个 tension(张力)是 0.5 的 Cardinal Spline (基数样条) http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline @ingroup Actions */ class CC_DLL CatmullRomBy : public CardinalSplineBy { public: /** 使用 points(点阵列)、 tension(张力)、duration创建一个 action * @code * 当这个函数绑定到 js or lua,输入参数会改变 * in js: var create(var dt,var table) * in lua: lcaol create(local dt, local table) * @endcode */ static CatmullRomBy* create(float dt, PointArray* points); /** 使用 points(点阵列)、duration创建一个 action */ bool initWithDuration(float dt, PointArray* points); // Override virtual CatmullRomBy *clone() const override; virtual CatmullRomBy *reverse() const override; }; /** Returns 根据给定的 控制点、tension(张力)、time 返回 Cardinal Spline 的位置 */ extern CC_DLL Point ccCardinalSplineAt(Point &p0, Point &p1, Point &p2, Point &p3, float tension, float t); // end of actions group /// @} NS_CC_END; #endif // __CCACTION_CATMULLROM_H__
相关文章推荐
- cocos2d-x节点(CCActionCamera.h)API
- cocos2d-x节点(CCActionEase.h)API
- cocos2d-x节点(CCActionGrid.h)API
- cocos2d-X 节点(CCActionFrameEasing.h)API
- cocos2d-X 节点(CCActionFrame.h)API
- cocos2d-x节点(CCActionInstant.h)API
- cocos2d-X 节点(CCActionManagerEx.h)API
- cocos2d-X 节点(CCActionNode.h)API
- cocos2d-X 节点(CCActionObject.h)API
- cocos2d-x节点(CCActionProgressTimer.h)API
- CCActionCatmullRom源码解析
- cocos2d-x节点(CCActionTiledGrid.h)API
- cocos2d-x节点(CCActionTween.h)API
- cocos2d-X 节点(CCAction.h)API
- cocos2d-X 节点(CCActionManager.h)API
- cocos2d-x节点(CCPhysicsSetting.h)API
- cocos2d-x节点(CCTransition.h)API
- cocos2d-x节点(CCEventListenerKeyboard.h)API
- cocos2d-x节点(CCAutoreleasePool.h)API
- cocos2d-X 节点(CCMotionStreak.h)API