Book Image

Corona SDK Mobile Game Development: Beginner's Guide

By : Michelle M Fernandez
Book Image

Corona SDK Mobile Game Development: Beginner's Guide

By: Michelle M Fernandez

Overview of this book

Table of Contents (19 chapters)
Corona SDK Mobile Game Development Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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:

  1. Create a new local function called hud():

    local hud = function()
  2. Display helpText at the start of the game for 10 seconds. Have it transition by sliding it to the left and turning visibility to false. Add helpText to the hudGroup 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 })
  3. Display counter and scoreText near the top of the screen. Add scoreText to the hudGroup group as well. Close the function with end:

      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...