Make Them Collide But Not Fall

A game is not a game if nothing collides, but not all games need physics! The physics engine offers the simplest way to deal With collisions; however, adding a body to an object makes it fall on the screen. Funny, but useless!

Using Physics Without Physics

In this lesson, we’ll deactivate all the behaviors of physics to retain only the collision part. You have just 2 simple things to do to keep the collisions active but not the physics behavior:

  • 1) Remove the effects of gravity:

    ifig0113.jpg
  • 2) Use dynamic sensor bodies:

Then we need to raise an event when a collision occurs:

What about using our FrameBall example ...

Get Create 2D Mobile Games with Corona SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.