cocos2d-X CCArmatureAnimation

来源:互联网 发布:淘宝客优惠券采集插件 编辑:程序博客网 时间:2024/05/16 09:24

armature (衔铁)动画

[cpp] view plaincopy在CODE上查看代码片派生到我的代码片
  1. ///cocos2d-x-3.0alpha0/extensions/CocoStudio/Armature/animation  
  2. //armature (衔铁)动画  
  3.   
  4.   
  5. #ifndef __CCANIMATION_H__  
  6. #define __CCANIMATION_H__  
  7.   
  8. #include "CCProcessBase.h"  
  9.   
  10. NS_CC_EXT_ARMATURE_BEGIN  
  11.   
  12.   
  13. enum MovementEventType  
  14. {  
  15.     START,  
  16.     COMPLETE,  
  17.     LOOP_COMPLETE  
  18. };  
  19.   
  20.   
  21. class Armature;  
  22. class Bone;  
  23.   
  24. typedef void (Object::*SEL_MovementEventCallFunc)(Armature *, MovementEventType, const char *);  
  25. typedef void (Object::*SEL_FrameEventCallFunc)(Bone *, const char *, intint);  
  26.   
  27. #define movementEvent_selector(_SELECTOR) (SEL_MovementEventCallFunc)(&_SELECTOR)  
  28. #define frameEvent_selector(_SELECTOR) (SEL_FrameEventCallFunc)(&_SELECTOR)  
  29.   
  30.   
  31. class  ArmatureAnimation : public ProcessBase  
  32. {  
  33. public:  
  34.     /** 
  35.      * 使用  armature (衔铁) 创建 
  36.      * @param armature ArmatureAnimation 将绑定到 Armature 
  37.      */  
  38.     static ArmatureAnimation *create(Armature *armature);  
  39. public:  
  40.     /** 
  41.      * @js ctor 
  42.      */  
  43.     ArmatureAnimation();  
  44.     /** 
  45.      * @js NA 
  46.      * @lua NA 
  47.      */  
  48.     virtual ~ArmatureAnimation(void);  
  49.   
  50.     /** 
  51.      * 使用 Armature 初始化 
  52.      * @param armature ArmatureAnimation 将绑定到 Armature 
  53.      */  
  54.     virtual bool init(Armature *armature);  
  55.   
  56.     /** 
  57.      * 动画缩放。 
  58.      * @param animationScale 缩放值 
  59.      */  
  60.     virtual void setAnimationScale(float animationScale);  
  61.     virtual float getAnimationScale() const;  
  62.   
  63.     /** 
  64.      * 缩放速度 
  65.      * @param animationScale 缩放值 
  66.      */  
  67.     virtual void setSpeedScale(float speedScale);  
  68.     virtual float getSpeedScale() const;  
  69.   
  70.     //! 动画更新速度  
  71.     virtual void setAnimationInternal(float animationInternal);  
  72.   
  73.     /** 
  74.      * 使用动画名播放动画 
  75.      * 
  76.      * @param  animationName  你希望播放的动画名 
  77.      * @param  durationTo 两个动画 changing-over(变化结束)之间的帧. 
  78.      *         这个动画需要改变多少个帧 
  79.      * 
  80.      *         -1 : MovementData 使用这个值从动画设计面板里面获取 
  81.      * @param  durationTween  你想在游戏中播放的帧的数量。 
  82.      *        如果_durationTween是80,那么动画将在一个循环中播放80帧 
  83.      * 
  84.      *         -1 : MovementData 使用这个值从动画设计面板里面获取 
  85.      * 
  86.      * @param  loop   动画是否循环 
  87.      * 
  88.      *         loop < 0 : MovementData 使用这个值从动画设计面板里面获取 
  89.      *         loop = 0 : this animation is not loop 
  90.      *         loop > 0 : this animation is loop 
  91.      * 
  92.      * @param  tweenEasing Tween easing 用于计算慢动作效果 
  93.      * 
  94.      *         TWEEN_EASING_MAX : MovementData 使用这个值从动画设计面板里面获取 
  95.      *         -1 : fade out        淡出 
  96.      *         0  : line 
  97.      *         1  : fade in             淡入 
  98.      *         2  : fade in and out  淡入淡出 
  99.      * 
  100.      */  
  101.     void play(const char *animationName, int durationTo = -1, int durationTween = -1,  int loop = -1, int tweenEasing = TWEEN_EASING_MAX);  
  102.   
  103.     /** 
  104.      * 通过索引播放动画,其他的参数也一样缩放 
  105.      * @param  _animationIndex  你希望播放的动画索引 
  106.      */  
  107.     void playByIndex(int animationIndex,  int durationTo = -1, int durationTween = -1,  int loop = -1, int tweenEasing = TWEEN_EASING_MAX);  
  108.   
  109.     /** 
  110.      * Pause the Process(处理)        //暂停 
  111.      */  
  112.     virtual void pause();  
  113.     /** 
  114.      * Resume the Process(处理)       //恢复 
  115.      */  
  116.     virtual void resume();  
  117.     /** 
  118.      * Stop the Process(处理)         //停止 
  119.      */  
  120.     virtual void stop();  
  121.   
  122.   
  123.     /** 
  124.      * Get movement count           //获取移动次数 
  125.      */  
  126.     int getMovementCount();  
  127.   
  128.     void update(float dt);  
  129.   
  130.     /** 
  131.      * Get current movementID               //  获取当前移动 ID 
  132.      * @return The name of current movement     //当前 移动的名字 
  133.      */  
  134.     std::string getCurrentMovementID();  
  135.   
  136.     /** 设置 armature (衔铁) 移动 事件的回调函数 
  137.      *  
  138.      * 断开这个事件只要调用 setMovementEventCallFunc(NULL, NULL); 
  139.      */  
  140.     void setMovementEventCallFunc(Object *target, SEL_MovementEventCallFunc callFunc);  
  141.   
  142.     /** 
  143.      * 设置 armature (衔铁) 帧 事件的回调函数 
  144.      * 断开这个事件只要调用 setFrameEventCallFunc(NULL, NULL); 
  145.      */  
  146.     void setFrameEventCallFunc(Object *target, SEL_FrameEventCallFunc callFunc);  
  147.   
  148. protected:  
  149.   
  150.     /** 
  151.      * Update(float dt) 将调用此处理程序,您可以在这里处理你的逻辑 
  152.      */  
  153.     void updateHandler();  
  154.   
  155.     /** 
  156.      * 更新当前关键帧,并处理自动停止,暂停 
  157.      */  
  158.     void updateFrameData(float currentPercent);  
  159.   
  160.     /** 
  161.      * Emit a frame event       //发出帧事件 
  162.      */  
  163.     void frameEvent(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex);  
  164.   
  165.     friend class Tween;  
  166. protected:  
  167.     //! AnimationData save all MovementDatas this animation used.       //使用这个动画的 AnimationData保存所有MovementDatas  
  168.     CC_SYNTHESIZE_RETAIN(AnimationData *, _animationData, AnimationData);  
  169.   
  170.     //! Scale the animation speed           //缩放动画速度  
  171.     float _speedScale;  
  172.   
  173.     MovementData *_movementData;                //! MovementData save all MovementFrameDatas this animation used.       //使用这个动画的 AnimationData保存所有MovementDatas  
  174.   
  175.     Armature *_armature;                        //! A weak reference of armature        //一个 armature 的弱引用  
  176.   
  177.     std::string _movementID;                //! Current movment's name          //当前移动的名字  
  178.   
  179.     int _toIndex;                               //! The frame(帧) index in MovementData->m_pMovFrameDataArr, it's different from m_iFrameIndex.  
  180.   
  181.     Array *_tweenList;  
  182.   
  183. protected:  
  184.     /** 
  185.      * MovementEvent CallFunc.              //移动事件回调函数 
  186.      * @param Armature* a Armature 
  187.      * @param MovementEventType, Event Type, like START, COMPLETE.          //事件类型 、完整 
  188.      * @param const char*, Movement ID, also called Movement Name 
  189.      */  
  190.     SEL_MovementEventCallFunc _movementEventCallFunc;  
  191.   
  192.     /** 
  193.      * FrameEvent CallFunc. 
  194.      * @param Bone*, a Bone 
  195.      * @param const char*, the name of this frame event 
  196.      * @param int, origin frame index 
  197.      * @param int, current frame index, animation may be delayed (延迟) 
  198.      */  
  199.     SEL_FrameEventCallFunc _frameEventCallFunc;  
  200.   
  201.   
  202.     Object *_movementEventTarget;  
  203.     Object *_frameEventTarget;  
  204. };  
  205.   
  206. NS_CC_EXT_ARMATURE_END  
  207.   
  208. #endif /*__CCANIMATION_H__*/  
0 0
原创粉丝点击