SFML Tiled collision

(Andrew) #1

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.

(Thorbjørn Lindeijer) #2

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.