Now we're going to display our information on the screen:
First of all, we need to define a font in
game.lua
inside theresource_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.Let's go back to
hud.lua
, create a method calledinitializeDebugHud
, and call it fromHUD:initialize
:function HUD:initializeDebugHud () self.font = MOAIFont.new () self.font = ResourceManager:get ( "hudFont" )
We use the font resource that we've just created as the font for our textboxes:
self.leftRightIndicator = self:newDebugTextBox ( 30, {10, 10, 100, 50} ) self.positionIndicator...