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

Creating the scene

We'll now create the necessary code to define a level. We won't be messing with sprites for it; instead we'll just use the default debug shapes from Box2D. We'll create the entire physical world, and you should now be able to assign sprites to it (it's the same as what we did with the player).

  1. First of all, we need to remove all the code that relates to the floor definition in physics_manager.lua, since now we'll be creating the floor with the rest of the platforms.
  2. Now, on game.lua, just below the background_objects definitions, we'll create a definition for the scene:
    local scene_objects = { floor = { type = MOAIBox2DBody.STATIC, position = {0, -WORLD_RESOLUTION_Y/2}, friction = 0, size = {2 * WORLD_RESOLUTION_X, 10} } platform1 ...

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