This question isn’t about animating individual tiles in a tileset, it’s about animating the gids in a tilemap.
I’ve cloned Stage 3 of Gradius - the level with the big stone “Moai” heads, which open and close their mouths and can be destroyed. The heads graphics themselves are stored in the tile data.
To change a head between the mouth closed, mouth open and destroyed states at runtime, the gids that make up the section of the tilelayer containing the head need to be changed (I’m using baylej/tmx btw).
To accomplish this it is necessary to have a “frame” of animation data for each the open, closed, destroyed etc states available. To get the frame data into the game, I’ve created a second tilelayer (not rendered) in my .tmx file called “Brush” which I load at runtime:
When the state of a head changes, I use a little helper function to copy the gids from the frame of data in the Brush layer into the layer that is actually rendered.
I’ve also added an object layer which is used to define the position and type of head by the game, so I know where to draw them and which way they should face (I use flipping)
This all works fine, but I was just wondering if’d I’d overlooked a better way of authoring the tilelayer animation data and getting it into the game. Thanks for any tips!