tiled icon indicating copy to clipboard operation
tiled copied to clipboard

Support multiple named animations per Tile

Open Rialgar opened this issue 10 years ago • 9 comments

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.

Rialgar avatar Jun 16 '15 21:06 Rialgar

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>
...

IMMZ avatar Aug 06 '15 09:08 IMMZ

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.

bjorn avatar Aug 06 '15 12:08 bjorn

Just adding a note that this request was also mentioned on the forum.

bjorn avatar Sep 12 '18 21:09 bjorn

There is a bounty on this issue, so it should probably have a bounty tag.

Phlosioneer avatar Dec 17 '19 16:12 Phlosioneer

@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.

bjorn avatar Dec 17 '19 16:12 bjorn

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.

joereynolds avatar Oct 13 '23 12:10 joereynolds

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.

eishiya avatar Oct 13 '23 13:10 eishiya

@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.

bjorn avatar Oct 16 '23 08:10 bjorn

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) :)

joereynolds avatar Oct 17 '23 08:10 joereynolds