O'Reilly logo

Developing Mobile Games with Moai SDK by Francisco Tufro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Real-world Physics with Box2D

If you've already worked on games before, you should be familiar with Box2D. It's a multiplatform physics library that is broadly used across the gaming community. You'll find it really easy to work with it and get nice-looking physics pretty quickly, but this doesn't mean you have to create another Angry Birds clone, hint hint.

Creating the world

The first step is to create the world that will be in charge of the physics simulation by following the given steps:

  1. Create a file called physics_manager.lua and require it from game.lua.
  2. Now let's build the PhysicsManager module.
    module ( "PhysicsManager", package.seeall )
    function PhysicsManager:initialize ( layer )
    1. The first step is to create the MOAIBox2DWorld

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required