diff --git a/core/2d/FastTMXLayer.cpp b/core/2d/FastTMXLayer.cpp index 676d34247106..b96eddd8d2a6 100644 --- a/core/2d/FastTMXLayer.cpp +++ b/core/2d/FastTMXLayer.cpp @@ -1041,8 +1041,9 @@ void TMXTileAnimTask::stop() void TMXTileAnimTask::setCurrFrame() { - _layer->setTileGID(_animation->_frames[_currentFrame]._tileID, _tilePosition, (TMXTileFlags)_flag); - _currentFrame = (_currentFrame + 1) % _frameCount; + _currentFrame = _nextFrame; + _layer->setTileGID((int)_animation->_frames[_currentFrame]._tileID, _tilePosition, (TMXTileFlags)_flag); + _nextFrame = (_currentFrame + 1) % _frameCount; } TMXTileAnimTask* TMXTileAnimTask::create(FastTMXLayer* layer, TMXTileAnimInfo* animation, const Vec2& tilePos, uint32_t flag) diff --git a/core/2d/FastTMXLayer.h b/core/2d/FastTMXLayer.h index 6b4a7cd861c6..09b597c2e394 100644 --- a/core/2d/FastTMXLayer.h +++ b/core/2d/FastTMXLayer.h @@ -425,6 +425,7 @@ class AX_DLL TMXTileAnimTask : public Object TMXTileAnimInfo* _animation = nullptr; /** Index of the frame that should be drawn currently */ uint32_t _currentFrame = 0; + uint32_t _nextFrame = 0; uint32_t _frameCount = 0; };