Question

I'm reading cocos2dx API, quite cant understand durationTo variable. Anybody can give me a clue?

 /**
 * Play animation by animation name.
 *
 * @param  animationName  The animation name you want to play
 * @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
 * @param  loop   Whether the animation is loop
 *
 *         loop < 0 : use the value from MovementData get from flash design panel
 *         loop = 0 : this animation is not loop
 *         loop > 0 : this animation is loop
 */
 virtual void play(const std::string& animationName, int durationTo = -1,  int loop = -1);
Was it helpful?

Solution

It means "how many frames between animation changes"

check out cocos2d/base/editor-support/cocostudio/CCProcessBase.cpp for a function ::play()

void ProcessBase::play(int durationTo, int durationTween,  int loop, int tweenEasing)
{
    _isComplete = false;
    _isPause = false;
    _isPlaying = true;
    _currentFrame = 0;

    /*
     *  Set m_iTotalFrames to durationTo, it is used for change tween between two animation.
     *  When changing end, m_iTotalFrames will be setted to _durationTween
    */
    _nextFrameIndex = durationTo;
    _tweenEasing = (cocos2d::tweenfunc::TweenType)tweenEasing;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top