Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

7. Physics: Falling Objects > Time for action – designing the HUD

Time for action – designing the HUD

While trying to make the player's gaming experience an enjoyable one, it's important that the information displayed is relevant to the game and placed strategically so it doesn't interfere with the main gaming area.

  1. Create a new local function called hud().
        local hud = function()
  2. Display the text for the eggs that are caught during gameplay.
          eggText = display.newText( "Caught: " .. eggCount, 0, 0,
            "Arial", 45 )
          eggText:setTextColor( 255, 255, 255, 255 )
          eggText.xScale = 0.5; eggText.yScale = 0.5
          eggText.x = (480 - (eggText.contentWidth * 0.5)) - 15
          eggText.y = 305
          gameGroup:insert( eggText )
  3. Add in the text to track the lives.
          livesText = display.newText( "Lives: " .. gameLives, 0, 0,
            "Arial", 45 )
          livesText:setTextColor( 255, 255, 255, 255 )  --> white
          livesText.xScale = 0.5; livesText.yScale = 0.5  --> for   
            clear retina display text
          livesText.x = (480 - (livesText.contentWidth * 0.5)) - 15
          livesText.y = 15
          gameGroup:insert( livesText )

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial