tiled
tiled copied to clipboard
Support multiple named animations per Tile
I would really like to have multiple (named) animations on one tile, this is especially useful for objects, since these might change their animation during the game. Some examples:
- Collectibles that make a little splosh when collected
- Enemies that can walk, stand, die, ...
- A Goal that shows a nice animation when reached It would be great to have all these animation specifications in a single place, and I think the Tiled file would be an excellent location.
For the time being I will probably create each animation on the starting tile and add the names as custom properties.
I have no idea why the animations is linked to the tiles. I think it would be useful just save animations under the 'map' node, linking them to the map. The only thing to be change is tile ids - they should have absolute values (like on the layers), not relative to the tileset. It will allow to make animations from different tilesets and to have multiply animations on the map - easy and useful. Each animation should have 'id' and 'name' property then the users could find them on the map and set them to their objects in their code.
Idea looks like
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="50" height="50" tilewidth="32" tileheight="32" nextobjectid="12">
<animation id="0" name="character_walk">
<frame tileid="120" duration="100"/>
<frame tileid="121" duration="100"/>
<frame tileid="122" duration="100"/>
<frame tileid="123" duration="100"/>
<frame tileid="124" duration="100"/>
<frame tileid="125" duration="100"/>
</animation>
<animation id="1" name="character_jump">
<frame tileid="15" duration="100"/>
<frame tileid="16" duration="100"/>
<frame tileid="17" duration="100"/>
<frame tileid="18" duration="100"/>
<frame tileid="19" duration="100"/>
</animation>
...
The reason animations are defined in the tileset is because the expectation is that you will define the animation once, then save it along with an (external) tileset, and use this tileset in many maps. If the animation was saved in the map, then the only way to use it in another map is to copy it over. And then it also gets really annoying when you want to change that animation, because of having multiple copies.
Defining animations using frames from multiple tilesets seemed like a very rare use-case in comparison, so I decided not to support that.
Just adding a note that this request was also mentioned on the forum.
There is a bounty on this issue, so it should probably have a bounty tag.
@Phlosioneer Thanks for checking the bounties. I've opted to simply delete that tag since there really isn't much happening with BountySource to make it worth it. Any bounties still active on BountySource remain valid though.
I'm also keen to see this in but I have a feeling it's quite low priority.
Is this sort of thing possible to do via a javascript extension or is the extension not able to write to .tsx files?
I quite like the XML changes that @IMMZ suggested (though not on the map) and I'd be happy to write an extension if possible.
Is this sort of thing possible to do via a javascript extension or is the extension not able to write to .tsx files?
Scripts can write TSX files, but specification-compliant TSX files can't store multiple lists of animations and existing TSX loaders probably won't load them, and Tiled can't preview multiple animations per tile.
Something you can already do is put all the animations on the tile as a single long animation, and use custom properties to tell your engine which frames belong to which animation. Scripting could even be used to preview these in Tiled, by temporarily removing the frames for other animations.
@joereynolds Did you consider adding this feature to Tiled directly, rather than going through the scripting API? It would be preferable for this kind of feature, and I can provide some guidance when necessary.
I've never touched C++ but I'm open to giving it a try if I find the time. Thanks for the help (if I end up needing it) :)