SFML Tiled collision

Whenever I use the collision editor to place collision detectors, e.g. boxes, polylines, on tiles and then export the .tmx file, the xml does not actually change.

My question is, what is the best way to detect collisions with tiles using Tiled and SFML? For example, I have a tile with a barrel and I don’t want my sprite to be able to run through it.

You can use the Tile Collision Editor, but the collision shapes are stored as part of the tileset, so the .tsx file changes and not the .tmx file.

I can’t really help you here because I do not know the functionality of SFML. Also, it depends on your game. If the shape of the barrel is relevant or you need it to roll around, you’ll probably want to use a physics library. But if it’s just a tile that you can’t pass through, then flagging is with a custom boolean property and checking this in your game logic may be enough.

1 Like

Just say that I got a similar issue recently. I embedded the tileset in the tilemap, and I removed some collision polygons from the Tile Collision Editor. However, after I exported the tilemap to json, these polygons were still in the tileset in the new exported json.