animation/CCProcessBase

来源:互联网 发布:分水岭算法区域增长 编辑:程序博客网 时间:2024/05/29 04:06

#ifndef __CCPROCESSBASE_H__

#define __CCPROCESSBASE_H__


#include "../utils/CCArmatureDefine.h"

#include "../datas/CCDatas.h"


NS_CC_EXT_BEGIN


enum AnimationType

{

    SINGLE_FRAME = -4,          //! the animation just have one frame

    ANIMATION_NO_LOOP,          //! the animation isn't loop


    ANIMATION_TO_LOOP_FRONT,    //! the animation loop from front

    ANIMATION_TO_LOOP_BACK,     //! the animation loop from back


    ANIMATION_LOOP_FRONT,       //! the animation loop from front

    ANIMATION_LOOP_BACK,        //! the animation loop from back


    ANIMATION_MAX,


};



class  CCProcessBase : public CCObject

{

public:

    CCProcessBase(void);

    ~CCProcessBase(void);


    /**

     * Play animation by animation name.

     *

     * @param  animation  It will not used in the CCProcessBase Class

     * @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 CCMovementData get from flash design panel

     * @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 CCMovementData get from flash design panel

     *

     * @param  loop   Whether the animation is loop

     *

     *         loop < 0 : use the value from CCMovementData get from flash design panel

     *         loop = 0 : this animation is not loop

     *         loop > 0 : this animation is loop

     *

     * @param  tweenEasing CCTween easing is used for calculate easing effect

     *

     *         TWEEN_EASING_MAX : use the value from CCMovementData get from flash design panel

     *         -1 : fade out

     *         0  : line

     *         1  : fade in

     *         2  : fade in and out

     *

     */

    virtual void play(void *animation, int durationTo, int durationTween,  int loop, int tweenEasing);


    /**

     * Pause the Process

     */

    virtual void pause();

    /**

     * Resume the Process

     */

    virtual void resume();

    /**

     * Stop the Process

     */

    virtual void stop();



    virtual void gotoFrame(int frameIndex);


    /**

     * You should never call this function, unless you know what you do

     * Update the Process, include current process, current frame and son on

     *

     * @param The duration since last update

     */

    virtual void update(float dt);


    virtual int getCurrentFrameIndex();


protected:



    /**

     * Update(float dt) will call this handler, you can handle your logic here

     */

    virtual void updateHandler() {};


protected:

//! Scale the animation speed

CC_SYNTHESIZE_PASS_BY_REF(float, m_fAnimationScale, AnimationScale);


    //! Set and get whether the aniamtion is pause

    CC_SYNTHESIZE_PASS_BY_REF(bool, m_bIsPause, IsPause);


    //! Set and get whether the aniamtion is complete

    CC_SYNTHESIZE_PASS_BY_REF(bool, m_bIsComplete, IsComplete);


    //! Set and get whether the aniamtion is playing

    CC_SYNTHESIZE_PASS_BY_REF(bool, m_bIsPlaying, IsPlaying);


    //! Current percent this process arrived

    CC_SYNTHESIZE_PASS_BY_REF(float, m_fCurrentPercent, CurrentPercent);


    //! The raw duration

    CC_SYNTHESIZE_PASS_BY_REF(int, m_iRawDuration, RawDuration);


    //! The animation whether or not loop

    CC_SYNTHESIZE_PASS_BY_REF(AnimationType, m_eLoopType, LoopType);


    //! The tween easing effect

    CC_SYNTHESIZE_PASS_BY_REF(CCTweenType, m_eTweenEasing, TweenEasing);


    //! The animation update speed

    CC_SYNTHESIZE_PASS_BY_REF(float, m_fAnimationInternal, AnimationInternal);



protected:

    //! The durantion frame count will run

    int m_iDurationTween;


    //! Current frame this process arrived, this frame is tween frame

    float m_fCurrentFrame;

    //! Frame index it the time line

    int m_iCurFrameIndex;


    //! Next frame this process need run to

    int m_iNextFrameIndex;



    bool m_bIsLoopBack;

};


NS_CC_EXT_END


#endif /*__CCPROCESSBASE_H__*/


0 0