How to draw an animatedtile from Tiled

Hi everyone :grinning:

I’m developing a game with MonoGame and Tiled. Unfortunately i couldn’t grab the Animated Tile from Tiled. Is there any possibilty to get dircetly from Tiled an AnimatedTile and draw it?

This exists already:
TiledMapTilesetAnimatedTile tiledMapTilesetAnimatedTile;

Currently i have solved it by looping trough 2DSprites.

Any ideas?


What do you mean by “get dircetly from Tiled an AnimatedTile”?

Could you please post some code of what you’ve done so far?


While i’m working with Tiled i need to use Monogame Extended. Monogame Extended provides us some possibilities to load the TIled map in our game. = Content.Load<TiledMap>("PATH/TO/MAP");

That’s really nice, but I have an Avatar that I want to load and animate from Tiled too.
After a long search, I have not found any documentation related to my problem.

I just found from Monogame.Extended the “TiledMapTilesetAnimatedTile” Class but i cant really interact with it.

I realize the Tiled API is not completely intuitive. That’s something I’ve been working on improving for the next version.

One thing that might help is if you have a read of the TMX Map Format page. The C# classes follow a very similar structure. In other words, if you open up your TMX file in a text editor you might be able to figure out where your animated tile is located in the code.

For example, the TiledMap class has a Tilesets property that is a collection of tilesets in the map. The tilesets are named based on the texture they use. So you might be able to do something like this (off the top of my head):

var tileset = tiledMap.Tilesets.FirstOrDefault(t => t.Name == "mytileset");
var myTile = tileset.Tiles.FirstOrDefault(t => t.LocalTileIdentifier == 9);
var animatedTile = (TiledMapTilesetAnimatedTile) myTile;

and once you’ve got the animated tile you can get access to the animation frames and so on…

All of the data you need is in there and you can get to it but of course it hasn’t been designed for this use case yet so it’s a bit fiddly.

Thank for your quick response.

I have already managed to get the animatedTile. At this point i was able to get the TiledMapTilesetTileAnimationFrame.
Is there any possibility to cast/convert it to a Texture2D object or to draw it directly.

(Because the spritebatch.Draw method just accepts a Texture2D object)

Thank you very much for your Help.