axmol/extensions/cocostudio/CCProcessBase.h

181 lines
5.4 KiB
C
Raw Normal View History

2022-02-24 18:51:36 +08:00
/****************************************************************************
2020-10-17 16:32:16 +08:00
Copyright (c) 2013-2017 Chukong Technologies Inc.
2013-06-06 12:02:54 +08:00
2022-08-08 18:02:17 +08:00
https://axys1.github.io/
2013-06-06 12:02:54 +08:00
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 "CCArmatureDefine.h"
#include "CCDatas.h"
#include "CocosStudioExport.h"
2013-06-06 12:02:54 +08:00
2021-12-25 10:04:45 +08:00
namespace cocostudio
{
2013-06-06 12:02:54 +08:00
enum AnimationType
{
2021-12-25 10:04:45 +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
2021-12-25 10:04:45 +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
2021-12-25 10:04:45 +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
};
/**
* @js NA
* @lua NA
*/
2022-08-08 18:02:17 +08:00
class CCS_DLL ProcessBase : public ax::Ref
2013-06-06 12:02:54 +08:00
{
public:
2020-10-17 16:32:16 +08:00
ProcessBase(void);
virtual ~ProcessBase(void);
2013-06-07 10:52:32 +08:00
/**
* Play animation by animation name.
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
*
*/
2021-12-25 10:04:45 +08:00
virtual void play(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();
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-11-05 19:53:38 +08:00
virtual void setProcessScale(float processScale) { _processScale = processScale; }
virtual float getProcessScale() const { return _processScale; }
virtual void setIsPause(bool pause) { _isPause = pause; }
virtual bool isPause() const { return _isPause; }
virtual void setIsComplete(bool complete) { _isComplete = complete; }
virtual bool isComplete() const { return _isComplete; }
virtual void setIsPlaying(bool playing) { _isPlaying = playing; }
virtual bool isPlaying() const { return _isPlaying; }
virtual float getCurrentPercent() const { return _currentPercent; }
virtual int getRawDuration() const { return _rawDuration; }
2013-06-06 12:02:54 +08:00
protected:
2013-10-30 09:41:40 +08:00
virtual void gotoFrame(int frameIndex);
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
*/
2021-12-25 10:04:45 +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-11-05 19:53:38 +08:00
float _processScale;
2013-06-06 12:02:54 +08:00
//! Set and get whether the animation is pause
2013-11-05 19:53:38 +08:00
bool _isPause;
2013-06-07 10:52:32 +08:00
//! Set and get whether the animation is complete
2013-11-05 19:53:38 +08:00
bool _isComplete;
2013-06-06 12:02:54 +08:00
//! Set and get whether the animation is playing
2013-11-05 19:53:38 +08:00
bool _isPlaying;
2013-06-06 12:02:54 +08:00
2013-06-07 10:52:32 +08:00
//! Current percent this process arrived
2013-11-05 19:53:38 +08:00
float _currentPercent;
2013-06-06 12:02:54 +08:00
2013-06-07 10:52:32 +08:00
//! The raw duration
2013-11-05 19:53:38 +08:00
int _rawDuration;
2013-06-07 10:52:32 +08:00
//! The animation whether or not loop
2013-11-05 19:53:38 +08:00
AnimationType _loopType;
2013-06-07 10:52:32 +08:00
//! The tween easing effect
2022-08-08 18:02:17 +08:00
ax::tweenfunc::TweenType _tweenEasing;
2013-06-06 12:02:54 +08:00
//! The animation update speed
2013-11-05 19:53:38 +08:00
float _animationInternal;
2013-06-06 12:02:54 +08:00
protected:
//! The duration 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
};
2021-12-25 10:04:45 +08:00
} // namespace cocostudio
2013-06-06 12:02:54 +08:00
2013-06-07 10:52:32 +08:00
#endif /*__CCPROCESSBASE_H__*/