Can I export the ID and Location of each image in a sprite sheet

Hi,

I’ve just started working on a game as part of a learning exercise and was wondering if I can somehow extract the coordinates and the ID that I see in Tiled into a list of sorts.

Currently I’m using a sprite sheet and when creating the tile map it exports to csv perfectly using the id of the sprite.

I’m only using a few sprites at the moment so there isn’t too much hassle in manually creating a list or a map of [id, (x, y)] so that I can simply pass in the ID when selecting what sprite should be drawn for which tile. As the map grows and has more and more images from the sheet this will become much more painful so I was wondering if I could shortcut that process and export the metadata from the sprite sheet automatically?

There’s every possibly the option exists and I’ve completely missed it, very equal chance that I’m just talking rubbish as well.

Thanks in advance for any help!

This option doesn’t exist because the location of a tile can be derived from its ID, since for spritesheets the ID is an index. This is explained quite well in the Tiled Tip Sheet under “Based on Tileset Image”. If you don’t use any “margin” or “spacing” the calculations can be further simplified.

If you really prefer to read the tile locations from a file, you could write a custom exporter in JavaScript that includes this information, based on each tile’s imageRect property.

that’s perfect, thank you so much! A small function later and it’s working beautifully.

1 Like