Skip to content

Commit

Permalink
Fix tile animation logic to use correct time per frame (#2345)
Browse files Browse the repository at this point in the history
Fix logic to get correct time per frame
  • Loading branch information
rh101 authored Jan 21, 2025
1 parent 86758c4 commit 336af86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/2d/FastTMXLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions core/2d/FastTMXLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit 336af86

Please # to comment.