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 that it doesn't interfere with the main gaming area. So, to design the HUD, perform the following steps:
Create a new local function called
hud()
:local hud = function()
Display the text for the eggs that are caught during game play:
eggText = display.newText( "Caught: " .. eggCount, 0, 0, "Arial", 45 ) eggText:setTextColor( 1, 1, 1 ) eggText.xScale = 0.5; eggText.yScale = 0.5 eggText.x = (480 - (eggText.contentWidth * 0.5)) - 15 eggText.y = 305 gameGroup:insert( eggText )
Add in text to track the lives:
livesText = display.newText( "Lives: " .. gameLives, 0, 0, "Arial", 45 ) livesText:setTextColor( 1, 1, 1 )--> white livesText.xScale = 0.5; livesText.yScale = 0.5 --> for clear retina display text livesText.x = (480 - (livesText...