The TilemapKit Roadmap is yours! All the ideas and discussions
20 votes Vote

Integrate Collision Detection

Every platform game needs to know, when dynamic sprites collide with the background. To do this Tiled allows to define a collision layer per tile in a tile set. It would be very helpful to activate physics collision detection per tile by the Tilekit API. To do that, it would be sufficient to give access to a physicsbody template for each tile in the tileset and copy it to the physicsbody of the sprite, rendering the tile on the screen.

Holger , 06.09.2015, 08:47
Idea status: under consideration


sitterheim, 06.09.2015, 09:28
Collision layers are accessible (I think from the tileset) which are TKObjectLayer with TKObject instances on them. TKObject already has methods to convert them to CGPath or a CGPoint* array which can be used for physics.

So what's missing is to add methods to return a new (static by default, but optionally can be dynamic) SKPhysicsBody/CCPhysicsBody from an object, so that if a node using this physics body and the object's position would setup a collision at that location.

But also the renderer could just apply them to the tile sprites automatically. This should be optional though.
Holger, 06.09.2015, 09:52
Yes, the first way you described is possible today. I used collisionLayerForLocalTile to create the physics body. The drawback is, that you have the collision nodes twice, one in the tile layer as sprite node, rendering the the scene and one SKNode at the same position to add physics. Therefore I would prefer the second option. Also clipping not visible tiles of the tileset layer is done by tilekit already.

Leave a comment