axmol/extensions/CocoStudio/Armature/animation/CCProcessBase.h

175 lines
5.1 KiB
C
Raw Normal View History

2013-06-06 12:02:54 +08:00
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCPROCESSBASE_H__
#define __CCPROCESSBASE_H__
#include "../utils/CCArmatureDefine.h"
#include "../datas/CCDatas.h"
2013-09-13 18:07:37 +08:00
NS_CC_EXT_ARMATURE_BEGIN
2013-06-07 10:52:32 +08:00
2013-06-06 12:02:54 +08:00
enum AnimationType
{
2013-06-07 10:52:32 +08:00
SINGLE_FRAME = -4, //! the animation just have one frame
ANIMATION_NO_LOOP, //! the animation isn't loop
2013-06-06 12:02:54 +08:00
2013-06-07 10:52:32 +08:00
ANIMATION_TO_LOOP_FRONT, //! the animation loop from front
ANIMATION_TO_LOOP_BACK, //! the animation loop from back
2013-06-06 12:02:54 +08:00
2013-06-07 10:52:32 +08:00
ANIMATION_LOOP_FRONT, //! the animation loop from front
ANIMATION_LOOP_BACK, //! the animation loop from back
2013-06-06 12:02:54 +08:00
2013-06-07 10:52:32 +08:00
ANIMATION_MAX,
2013-06-06 12:02:54 +08:00
};
class ProcessBase : public Object
2013-06-06 12:02:54 +08:00
{
public:
2013-09-16 14:13:55 +08:00
/**
* @js ctor
*/
ProcessBase(void);
2013-09-16 14:13:55 +08:00
/**
* @js NA
* @lua NA
*/
~ProcessBase(void);
2013-06-07 10:52:32 +08:00
/**
* Play animation by animation name.
2013-06-06 12:02:54 +08:00
*
* @param animation It will not used in the ProcessBase Class
2013-06-06 12:02:54 +08:00
* @param durationTo The frames between two animation changing-over.
* It's meaning is changing to this animation need how many frames
*
* -1 : use the value from MovementData get from flash design panel
2013-06-06 12:02:54 +08:00
* @param durationTween The frame count you want to play in the game.
* if _durationTween is 80, then the animation will played 80 frames in a loop
*
* -1 : use the value from MovementData get from flash design panel
2013-06-06 12:02:54 +08:00
*
* @param loop Whether the animation is loop
*
* loop < 0 : use the value from MovementData get from flash design panel
2013-06-06 12:02:54 +08:00
* loop = 0 : this animation is not loop
* loop > 0 : this animation is loop
*
* @param tweenEasing Tween easing is used for calculate easing effect
2013-06-06 12:02:54 +08:00
*
* TWEEN_EASING_MAX : use the value from MovementData get from flash design panel
2013-06-06 12:02:54 +08:00
* -1 : fade out
* 0 : line
* 1 : fade in
* 2 : fade in and out
*
*/
2013-06-07 10:52:32 +08:00
virtual void play(void *animation, int durationTo, int durationTween, int loop, int tweenEasing);
2013-06-06 12:02:54 +08:00
/**
2013-06-07 10:52:32 +08:00
* Pause the Process
2013-06-06 12:02:54 +08:00
*/
2013-06-07 10:52:32 +08:00
virtual void pause();
2013-06-06 12:02:54 +08:00
/**
2013-06-07 10:52:32 +08:00
* Resume the Process
2013-06-06 12:02:54 +08:00
*/
2013-06-07 10:52:32 +08:00
virtual void resume();
2013-06-06 12:02:54 +08:00
/**
2013-06-07 10:52:32 +08:00
* Stop the Process
2013-06-06 12:02:54 +08:00
*/
2013-06-07 10:52:32 +08:00
virtual void stop();
virtual void gotoFrame(int frameIndex);
2013-06-06 12:02:54 +08:00
/**
* You should never call this function, unless you know what you do
* Update the Process, include current process, current frame and son on
*
2013-09-13 18:07:37 +08:00
* @param The duration since last update
2013-06-06 12:02:54 +08:00
*/
2013-06-07 10:52:32 +08:00
virtual void update(float dt);
2013-06-06 12:02:54 +08:00
virtual int getCurrentFrameIndex();
2013-06-07 10:52:32 +08:00
2013-06-06 12:02:54 +08:00
protected:
2013-06-07 10:52:32 +08:00
2013-06-06 12:02:54 +08:00
/**
2013-06-07 10:52:32 +08:00
* Update(float dt) will call this handler, you can handle your logic here
2013-06-06 12:02:54 +08:00
*/
2013-06-07 10:52:32 +08:00
virtual void updateHandler() {};
2013-06-06 12:02:54 +08:00
protected:
2013-09-13 18:07:37 +08:00
//! Scale the process speed
2013-09-15 20:24:25 +08:00
CC_SYNTHESIZE(float, _processScale, ProcessScale);
2013-06-06 12:02:54 +08:00
2013-06-07 10:52:32 +08:00
//! Set and get whether the aniamtion is pause
2013-09-15 20:24:25 +08:00
CC_SYNTHESIZE(bool, _isPause, IsPause);
2013-06-07 10:52:32 +08:00
2013-06-06 12:02:54 +08:00
//! Set and get whether the aniamtion is complete
2013-09-15 20:24:25 +08:00
CC_SYNTHESIZE(bool, _isComplete, IsComplete);
2013-06-06 12:02:54 +08:00
2013-06-07 10:52:32 +08:00
//! Set and get whether the aniamtion is playing
2013-09-15 20:24:25 +08:00
CC_SYNTHESIZE(bool, _isPlaying, IsPlaying);
2013-06-06 12:02:54 +08:00
2013-06-07 10:52:32 +08:00
//! Current percent this process arrived
2013-09-15 20:24:25 +08:00
CC_SYNTHESIZE(float, _currentPercent, CurrentPercent);
2013-06-06 12:02:54 +08:00
2013-06-07 10:52:32 +08:00
//! The raw duration
2013-09-15 20:24:25 +08:00
CC_SYNTHESIZE(int, _rawDuration, RawDuration);
2013-06-07 10:52:32 +08:00
//! The animation whether or not loop
2013-09-15 20:24:25 +08:00
CC_SYNTHESIZE(AnimationType, _loopType, LoopType);
2013-06-07 10:52:32 +08:00
//! The tween easing effect
2013-09-15 20:24:25 +08:00
CC_SYNTHESIZE(CCTweenType, _tweenEasing, TweenEasing);
2013-06-06 12:02:54 +08:00
//! The animation update speed
2013-09-15 20:24:25 +08:00
CC_SYNTHESIZE(float, _animationInternal, AnimationInternal);
2013-06-06 12:02:54 +08:00
2013-06-07 10:52:32 +08:00
2013-06-06 12:02:54 +08:00
protected:
//! The durantion frame count will run
2013-09-15 20:24:25 +08:00
int _durationTween;
2013-06-06 12:02:54 +08:00
2013-06-07 10:52:32 +08:00
//! Current frame this process arrived, this frame is tween frame
2013-09-15 20:24:25 +08:00
float _currentFrame;
2013-06-07 10:52:32 +08:00
//! Frame index it the time line
2013-09-15 20:24:25 +08:00
int _curFrameIndex;
2013-06-06 12:02:54 +08:00
2013-06-07 10:52:32 +08:00
//! Next frame this process need run to
2013-09-16 14:13:55 +08:00
int _nextFrameIndex;
2013-06-06 12:02:54 +08:00
2013-09-15 20:24:25 +08:00
bool _isLoopBack;
2013-06-06 12:02:54 +08:00
};
2013-09-13 18:07:37 +08:00
NS_CC_EXT_ARMATURE_END
2013-06-06 12:02:54 +08:00
2013-06-07 10:52:32 +08:00
#endif /*__CCPROCESSBASE_H__*/