Box2D only accepts convex shapes with 8 points or fewer. Most 2D levels contain shapes with more complex geometries. To solve this problem it's necessary to decompose the complex shape into a number of sub shapes each with it's own fixture. These fixtures are then added to the Box2D body.

You have to break up the shape into convex polygons with no more than 8 points. You could do this manually or you could use a triangulation or polygonization algorithm (there are a number that can be adapted from the internet). After you've polygonized the shape, you need to make a composite Box2D body. To do this, create a number of fixture each associated with one of the polygons. Then add all of these fixtures to the body. There's an example of this in the Shape Workshop bundle.

## Add new comment