Time for action – displaying the timer and score
Let's set up the help screen and HUD elements that need to be displayed during the game:
Create a new local function called
hud()
:local hud = function()
Display
helpText
at the start of the game for 10 seconds. Have it transition by sliding it to the left and turning visibility tofalse
. AddhelpText
to thehudGroup
group:local helpText = display.newImage("help.png") helpText.x = 240; helpText.y = 160 helpText.isVisible = true hudGroup:insert( helpText ) timer.performWithDelay( 10000, function() helpText.isVisible = false; end, 1 ) transition.to( helpText, { delay=9000, time=1000, x=-320, transition=easing.inOutExpo })
Display
counter
andscoreText
near the top of the screen. AddscoreText
to thehudGroup
group as well. Close the function withend
:counter = display.newText( "Time: " .. tostring(numSeconds), 0, 0, "Helvetica-Bold", counterSize ) counter:setFillColor( 1, 1, 1 ) counter.xScale = 0.5; counter.yScale = 0.5 counter...