Tiled animations not displaying properly

Hello, I’m using TiledMapRenderer, which is displaying static tiles just fine. However, when it tries to render an animated tile, it appears the source rectangle’s top left coordinate is always 0, 0, while the bottom right coordinate is correct. So instead of seeing each individual frame, I’m seeing all tiles from the top left of the texture to the current frame crammed into the destination rectangle. It is “animating” but the source rectangle just grows each frame until the animation restarts.

I am simply calling TiledMapRenderer.Draw(). Is there more to rendering animated tiles, or should that call be drawing them properly?

You should post the problem as a GitHub issue along with an example Tiled map and tileset.

Thanks. I just posted there with an example project.

Sorry for the thread necromancy, but did this ever get a comment or resolution? I’ve looked and seen no one else referring to this issue and I couldn’t find anything in the github, although i could have missed it.

As far as I’m aware Tiled animations work just fine in the latest version.

Ok thanks, I’ll try to update and see if that fixes the problem. I thought I tried that already but I’ll give it a go.

Error was lines 24 and 25 on TiledMapTileSetTileAnimationFrame.cs the (float) in front of sourceRectagnle.X and Y respectively wasn’t fixing the int division. It needs to be on the divisor apparently otherwise it gets set to 0.

At least, that’s what I’m seeing.

Hi, this is a bit old, but still not fixed in the latest builds. I believe what Syrinth said is true, though I haven’t tried it, I just looked at the piece of code.

I wrote the original code. While annoying to look at between left and right operand being cast to float, it really doesn’t matter. The compiler understands that we want the result to be a float because the division operation with either the left or the right operand is a float. The code should work as expected if you are using master branch since May 28th 2018.

These mushrooms (annoying as they may be) are animated in the latest source.

I don’t recall when this was fixed. You might need to build from source or use a pre-release package.

If there’s still an issue I don’t understand please raise it on github.