Create Complex Non-Convex bodies in Corona SDK

As we’re gearing towards the new release of YATS (which will implement a super cool physics support), we ported Antoon Angelov Convex Separator for Box2D Flash class to LUA and, more specifically, Corona SDK.

What does this do exactly? Box2D (the physics engine used by Corona) doesn’t support non-convex bodies. With this module, a non-convex body will be automatically separated into several fully supported bodies. We’ve also made sure that these bodies are properly placed on top of any particular object (be it a polygon, or any other display object) you pass to it, and that you’re also able to define parameters such as body type, density, friction and bounce.

This still wasn’t throughly tested for every scenario, but should be solid for the most common ones.

You can find the module and informations on how to use it on Gist and in the Corona Code Exchange



  1. Hey Guys, might seem like a moron for asking this, but what are Non-Convex bodies vs Convex bodies? ;)

    • No worries, it’s a pretty normal question! :D
      Convex Bodies are the only type of bodies supported by box2D, the physic engine used by Corona.
      It means that you can’t have concave bodies, it will not load correctly.

      This library (and an advanced implementation of it in YATS), makes it so that the body is automatically split into several, convex bodies, allowing you to draw any kind of shape (even concave ones) without preparing the different bodies in advance (but you just need to supply a single body).