I am in the process of making a game, at which point I recognized bleeding happening with the tiles. It looks like the solution to fixing the bleeding is adding padding. Currently I have 30 maps made with this tileset so I do not want to remake all of the maps.
So:
I used a gimp python script to add 1 pixel of padding to all of the tiles. (Resizes from 256 width to 288 width)
I edited all of the .tmx files to add spacing=“2” margin=“1” to my tags.
Load up the tiled map editor, and all of the tile ids for all the maps I load are off by 2 for every row (sometimes off by more) they are down in my tilemap. (Example: a tile on the second row has an ID of 21, on my maps those squares now have ID 23)
Is there something silly I am missing or does Tiled not handle adding margin and spacing to an existing tileset?
Apart from adjusting the spacing and margin attributes, did you also remember to adjust the width and height properties on the image element? If you don’t update the width, then Tiled thinks your image changed size because it was extended with more tiles, and will adjust the tile indexes accordingly. This would mess things up in your case.
Oh my gosh can’t believe I missed that. Adjusting the width and height fixes my issue. I wrote a program to decode and decrypt, adjust the indices then encrypt and encode them back into the tmx file haha. I couldnt quite get the index transformation correct though.
I’m trying to do the same (adding padding to an existing tilemap), but I can’t figure out the margin,spacing,width and height values to make it work.
I’m working on a 16x16 grid with tiles of the same size, and I want to set a 1 pixel padding, any help?
Dug up the code that fixed it. Notice I had to add the spacing and margin attributes, and updated width and height to match the newly padded tileset png.
Note that apart from adjusting those parameters in the tileset definition, you also need to adjust the actual tileset image. Given that Tiled only found 56 columns, it indicates that the cavetileset.png image was still only 1024px wide: