概述
armature (衔铁)动画
- ///cocos2d-x-3.0alpha0/extensions/CocoStudio/Armature/animation
- //armature (衔铁)动画
- #ifndef __CCANIMATION_H__
- #define __CCANIMATION_H__
- #include "CCProcessBase.h"
- NS_CC_EXT_ARMATURE_BEGIN
- enum MovementEventType
- {
- START,
- COMPLETE,
- LOOP_COMPLETE
- };
- class Armature;
- class Bone;
- typedef void (Object::*SEL_MovementEventCallFunc)(Armature *, MovementEventType, const char *);
- typedef void (Object::*SEL_FrameEventCallFunc)(Bone *, const char *, int, int);
- #define movementEvent_selector(_SELECTOR) (SEL_MovementEventCallFunc)(&_SELECTOR)
- #define frameEvent_selector(_SELECTOR) (SEL_FrameEventCallFunc)(&_SELECTOR)
- class ArmatureAnimation : public ProcessBase
- {
- public:
- /**
- * 使用 armature (衔铁) 创建
- * @param armature ArmatureAnimation 将绑定到 Armature
- */
- static ArmatureAnimation *create(Armature *armature);
- public:
- /**
- * @js ctor
- */
- ArmatureAnimation();
- /**
- * @js NA
- * @lua NA
- */
- virtual ~ArmatureAnimation(void);
- /**
- * 使用 Armature 初始化
- * @param armature ArmatureAnimation 将绑定到 Armature
- */
- virtual bool init(Armature *armature);
- /**
- * 动画缩放。
- * @param animationScale 缩放值
- */
- virtual void setAnimationScale(float animationScale);
- virtual float getAnimationScale() const;
- /**
- * 缩放速度
- * @param animationScale 缩放值
- */
- virtual void setSpeedScale(float speedScale);
- virtual float getSpeedScale() const;
- //! 动画更新速度
- virtual void setAnimationInternal(float animationInternal);
- /**
- * 使用动画名播放动画
- *
- * @param animationName 你希望播放的动画名
- * @param durationTo 两个动画 changing-over(变化结束)之间的帧.
- * 这个动画需要改变多少个帧
- *
- * -1 : MovementData 使用这个值从动画设计面板里面获取
- * @param durationTween 你想在游戏中播放的帧的数量。
- * 如果_durationTween是80,那么动画将在一个循环中播放80帧
- *
- * -1 : MovementData 使用这个值从动画设计面板里面获取
- *
- * @param loop 动画是否循环
- *
- * loop < 0 : MovementData 使用这个值从动画设计面板里面获取
- * loop = 0 : this animation is not loop
- * loop > 0 : this animation is loop
- *
- * @param tweenEasing Tween easing 用于计算慢动作效果
- *
- * TWEEN_EASING_MAX : MovementData 使用这个值从动画设计面板里面获取
- * -1 : fade out 淡出
- * 0 : line
- * 1 : fade in 淡入
- * 2 : fade in and out 淡入淡出
- *
- */
- void play(const char *animationName, int durationTo = -1, int durationTween = -1, int loop = -1, int tweenEasing = TWEEN_EASING_MAX);
- /**
- * 通过索引播放动画,其他的参数也一样缩放
- * @param _animationIndex 你希望播放的动画索引
- */
- void playByIndex(int animationIndex, int durationTo = -1, int durationTween = -1, int loop = -1, int tweenEasing = TWEEN_EASING_MAX);
- /**
- * Pause the Process(处理) //暂停
- */
- virtual void pause();
- /**
- * Resume the Process(处理) //恢复
- */
- virtual void resume();
- /**
- * Stop the Process(处理) //停止
- */
- virtual void stop();
- /**
- * Get movement count //获取移动次数
- */
- int getMovementCount();
- void update(float dt);
- /**
- * Get current movementID // 获取当前移动 ID
- * @return The name of current movement //当前 移动的名字
- */
- std::string getCurrentMovementID();
- /** 设置 armature (衔铁) 移动 事件的回调函数
- *
- * 断开这个事件只要调用 setMovementEventCallFunc(NULL, NULL);
- */
- void setMovementEventCallFunc(Object *target, SEL_MovementEventCallFunc callFunc);
- /**
- * 设置 armature (衔铁) 帧 事件的回调函数
- * 断开这个事件只要调用 setFrameEventCallFunc(NULL, NULL);
- */
- void setFrameEventCallFunc(Object *target, SEL_FrameEventCallFunc callFunc);
- protected:
- /**
- * Update(float dt) 将调用此处理程序,您可以在这里处理你的逻辑
- */
- void updateHandler();
- /**
- * 更新当前关键帧,并处理自动停止,暂停
- */
- void updateFrameData(float currentPercent);
- /**
- * Emit a frame event //发出帧事件
- */
- void frameEvent(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex);
- friend class Tween;
- protected:
- //! AnimationData save all MovementDatas this animation used. //使用这个动画的 AnimationData保存所有MovementDatas
- CC_SYNTHESIZE_RETAIN(AnimationData *, _animationData, AnimationData);
- //! Scale the animation speed //缩放动画速度
- float _speedScale;
- MovementData *_movementData; //! MovementData save all MovementFrameDatas this animation used. //使用这个动画的 AnimationData保存所有MovementDatas
- Armature *_armature; //! A weak reference of armature //一个 armature 的弱引用
- std::string _movementID; //! Current movment's name //当前移动的名字
- int _toIndex; //! The frame(帧) index in MovementData->m_pMovFrameDataArr, it's different from m_iFrameIndex.
- Array *_tweenList;
- protected:
- /**
- * MovementEvent CallFunc. //移动事件回调函数
- * @param Armature* a Armature
- * @param MovementEventType, Event Type, like START, COMPLETE. //事件类型 、完整
- * @param const char*, Movement ID, also called Movement Name
- */
- SEL_MovementEventCallFunc _movementEventCallFunc;
- /**
- * FrameEvent CallFunc.
- * @param Bone*, a Bone
- * @param const char*, the name of this frame event
- * @param int, origin frame index
- * @param int, current frame index, animation may be delayed (延迟)
- */
- SEL_FrameEventCallFunc _frameEventCallFunc;
- Object *_movementEventTarget;
- Object *_frameEventTarget;
- };
- NS_CC_EXT_ARMATURE_END
- #endif /*__CCANIMATION_H__*/
最后
以上就是稳重小笼包为你收集整理的cocos2d-X CCArmatureAnimation的全部内容,希望文章能够帮你解决cocos2d-X CCArmatureAnimation所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复