Merge pull request #12040 from geron-cn/v3

fix bug:  fix actiontimeline can not step to last frame when loop play
This commit is contained in:
pandamicro 2015-06-11 14:36:08 +08:00
commit 8e3e928efd
1 changed files with 13 additions and 8 deletions

View File

@ -199,23 +199,28 @@ void ActionTimeline::step(float delta)
}
_time += delta * _timeSpeed;
if(_time < _endFrame * _frameInternal)
const float endtoffset = _time - _endFrame * _frameInternal;
if (endtoffset < _frameInternal)
{
_currentFrame = (int)(_time / _frameInternal);
stepToFrame(_currentFrame);
if (endtoffset >= 0 && _lastFrameListener != nullptr) // last frame
_lastFrameListener();
}
else
{
if(_lastFrameListener != nullptr)
_lastFrameListener();
_playing = _loop;
if(!_playing)
if (!_playing)
{
_time = _endFrame * _frameInternal;
_currentFrame = (int)(_time / _frameInternal);
stepToFrame(_currentFrame);
if (_currentFrame != _endFrame)
{
_currentFrame = _endFrame;
stepToFrame(_currentFrame);
if (_lastFrameListener != nullptr) // last frame
_lastFrameListener();
}
}
else
gotoFrameAndPlay(_startFrame, _endFrame, _loop);