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

Left or right, that's the question

Now we're going to display our information on the screen:

  1. First of all, we need to define a font in game.lua inside the resource_definitions table.

    We provided one with the source code for this chapter, but you can use whatever font you like:

        hudFont ={
            type = RESOURCE_TYPE_FONT,
            fileName = 'fonts/tuffy.ttf',
        glyphs = 
        "abcdefghijklmnopqrstuvwxyzABCDEFGHI
        JKLMNOPQRSTUVWXYZ0123456789,.?!",
        fontSize = 26,
        dpi = 160
      }

    This should be familiar, since we talked about it in Chapter 6, Resource Manager.

    Now we know hudFont will reference our font.

  2. Let's go back to hud.lua, create a method called initializeDebugHud, and call it from HUD:initialize:
    function HUD:initializeDebugHud () self.font = MOAIFont.new () self.font = ResourceManager:get ...

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