The first step is to create the world that will be in charge of the physics simulation by following the given steps:
Create a file called
physics_manager.lua
andrequire
it fromgame.lua
.Now let's build the
PhysicsManager
module.module ( "PhysicsManager", package.seeall ) function PhysicsManager:initialize ( layer )
The first step is to create the
MOAIBox2DWorld
self.world = MOAIBox2DWorld.new ()
Then, we need to set up our scale. What we're doing here is saying that one meter on the simulation is equivalent to 38 points in our world coordinates. Since we're using a main character sprite that is 64 points tall, we can say that our character could be about 1.67 meters tall. So, 65 / 1.67 is about 38. That's the calculation needed in order to find that scale.
self.world:setUnitsToMeters ( 1/38 )