I was working with Tiled and I noticed that the numbering order that shows for the tile ID property in extra layer/tileset combos isn’t accurately reflected in the layers array when you export a map to JSON. The tile ID in Tiled shows that it starts at 1, just like the first tileset, but when you export it shows the numbers as starting at something random like 457.
I used 2 images that should have been straight stamp copies of the entire image (grass and trees) in the exact order they were already in (to test this, just highlighting the entire image for each tileset and stamping it onto 2 separate layers), and while the first layer and tileset did just fine (0 - however many tiles there were), the second layer and tileset started at the random ID number for the first tile and aggregated the values from there onward. Is Tiled aggregating the tile ID in the export from previous tiles in separate tilesets, and if so is there a way to disable this besides parsing and rewriting the JSON to account for it for each individual tileset? The images were not the same size, and I have not tested same size images yet to see if it has any relation to this bug.
It shouldn’t really matter for this bug, but just in case, I’m using Windows 10, testing rendering in a self-made JSON to canvas image script. The script does not alter the original JSON, just ajax pulls it (but again, if need be I can alter my script to manually account for this bug…it just wouldn’t be a solution for anyone else using any other system in combination with Tiled and the JSON export with multiple layers and multiple tilesets).
Currently I am working around this (working 1 layer at a time and copy pasting the layers JSON for each layer into a separate file where it will be ordered properly for the final render file), but its a hassle. I’m more than willing to help if isolating or resolving this bug requires another set of dev eyes.
I can provide more information, the images I am using to test or anything else necessary as requested. If this is intended behavior please just let me know and I will modify my script accordingly (but in that case, the tile ID in Tiled should probably reflect the aggregated value as well).
Yes, Tiled aggregates all tilesets used by the map because all tilesets can be used on all layers. There is no way to disable this, though as Ablu said you can quite easily map the numbers back to the local tile indexes by using the firstgid property of each tileset.