Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Animated tiles missing a tile/frame #61

Closed
ilyvion opened this issue Dec 14, 2024 · 1 comment · Fixed by #62
Closed

Animated tiles missing a tile/frame #61

ilyvion opened this issue Dec 14, 2024 · 1 comment · Fixed by #62
Labels
bug Something isn't working

Comments

@ilyvion
Copy link

ilyvion commented Dec 14, 2024

(with the caveat that I'm using the as-of-yet unmerged #45 PR since I'm on 0.15 and that this may not have been a problem in the earlier versions)

I tried using this crate for the first time and wanted to use animated tiles, but I noticed that a frame was always missing from the animation in Bevy compared to in Tiled. I looked through the relevant code and noticed that the AnimatedTile is created using last_tile.tile_id as its end value:

Some(AnimatedTile {
start: first_tile.tile_id,
end: last_tile.tile_id,
speed: 1000. / first_tile.duration as f32, // duration is in ms and we want a 'frames per second' speed
})

The documentation for AnimatedTile::end is "The end frame index in the tilemap atlas/array (exclusive)." That "exclusive" made me think that it might be necessary to add 1 to the last_tile.tile_id since we want to include the last tile of the animation that Tiled provides to us, not exclude it. And sure enough, by changing the code above to

Some(AnimatedTile {
    start: first_tile.tile_id,
    end: last_tile.tile_id + 1, // added a `+ 1` here
    speed: 1000. / first_tile.duration as f32, // duration is in ms and we want a 'frames per second' speed
})

my animated tiles are suddenly not missing tiles/frames anymore.

@adrien-bon adrien-bon added the bug Something isn't working label Dec 14, 2024
@adrien-bon
Copy link
Owner

Hi,
thanks for the issue!
Seems like it's a bug since the feature was added.
I'll fix that in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants