Search code examples
cocos2d-iphonecollision-detection

collision detection on non-full tiles in a Tilemap


If one creates a tile map from a tileset and there are tiles/squares that are not completely full, how Does on make these half filled tiles able to detect collision?

Its easy to select an area that is square and set it to e.g. collision yes

But how does one handle rounded edges that fill half a tile or a triangular shape that is just entering a tile?

Or does one create an entire layer and set it to collision yes that that tiles dont need to be check for collision?

Still, how does one detect the layer for collisions?

Thanks


Solution

  • The whole idea of a tile based system is that stuff fills an entire tile. You can apply normal collision detection approaches to tiles of course, or apply them on a per tile basis.

    Some games allow buildings to fill a whole tile, but still have units traverse tiles. This is often done by taking the 4 corner points (and 4 points at the center of the sides) and checking if a line between a few of these points doesn't collide with anything, if that is true then units can travel these lines.

    This is often pre-computed for every building that can occupy a tile.