Tilesource Animations

Hi,

I apologise if this is a common question but I haven’t seen it asked in a few years so I don’t know if it’s fixed. How do I animate tile maps?

I know you can create animation groups within tile sources (see below). But I cant work out how to trigger them to play.

The only alternative I have found is to use the “Defold Tilemap Animator” extension, but it seems a bit overkill when all I want is a simple loop-forwards animation I want to run continuously.

Defold doesn’t provide any built-in way to animate tilemaps. The animations you see in the Editor are actually meant to be applied to sprites… sprites can take their source image from either a tilesource or an atlas.

Defold Tilemap Animator was created to allow for your use-case. It’s pretty simple and doesn’t allocate much memory other than what’s specified by the user.

Another three options are:

  1. Create a shader to dynamically select texture coordinates as time progresses.
  2. Create multiple tilesources where each one contains a single animation step. For example, if you have eight animation steps for a tile of water, create eight tilesources and load them dynamically on a timer in a script. See the following thread for an example: Setting Tile Source at runtime question
  3. If your use-case is very simple, then use the tilemap.set_tile() API on a timer, which is a small part of what Defold Tilemap Animator does behind the scenes.
3 Likes