After letting this feature slack for a few month I decided to finally come back to this. The concept Bjørn suggested turns out to be not that practicable because it creates a horrible spaghetti code in the tilesets xml code. Here is an example of a tileset definition with just a single three-frame animation:
Code: Select all
<tileset name="woodland_ground" firstgid="3" tilewidth="32" tileheight="32">
<image source="../graphics/tiles/Woodland_ground.png"/>
<tile id="0">
<properties>
<property name="delay" value="100"/>
<property name="next-frame" value="16"/>
</properties>
</tile>
<tile id="16">
<properties>
<property name="delay" value="100"/>
<property name="next-frame" value="48"/>
</properties>
</tile>
<tile id="48">
<properties>
<property name="delay" value="100"/>
<property name="next-frame" value="0"/>
</properties>
</tile>
</tileset>
Just imagine how it would look with more animations with more frames.
First it is very hard to trace animation loops after they are created (the tileset property editor of tiled doesn't make it a lot easier).
Second it does not allow to use the same frame in multiple animations.
As a counter-proposal I would suggest to put the whole animation loop of a tile in the properties of the first tile of the loop. This allows to use the other tiles of the animation loop unanimated or as parts of other animations. Example with the same animation:
Code: Select all
<tileset name="woodland_ground" firstgid="3" tilewidth="32" tileheight="32">
<image source="../graphics/tiles/Woodland_ground.png"/>
<tile id="0">
<properties>
<property name="animation-frame0" value="0"/>
<property name="animation-delay0" value="100"/>
<property name="animation-frame1" value="16"/>
<property name="animation-delay1" value="100"/>
<property name="animation-frame2" value="48"/>
<property name="animation-delay2" value="100"/>
</properties>
</tile>
</tileset>
Much shorter, much easier to read (especially in Tileds tile property editor) and much less error-prone. The only aspect where this notation for animations is less powerful that the other is that it does not allow non-infinite loops. But these don't make much sense for map files in my opinion.
You will maybe note that the definition of the first frame (frame0) seems to be redundant. This is intentional. The tile should be represented with the normal id in tiled and with frame0 - frame2 by the engine. The idea is that you have a tileset for an animated tile consisting of the frames of the animation and one frame which is a duplicate of another frame with a big, red "A" for animated on it. You assign the animation loop to the "A" tile and use this for mapping in tiled. That way it is hard to confuse the animated tile with its subframes while editing a map.