Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix tile animation logic to use correct time per frame #2345

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading