Reader small image

You're reading from  Corona SDK Mobile Game Development: Beginner's Guide

Product typeBook
Published inMar 2015
Publisher
ISBN-139781783559343
Edition1st Edition
Tools
Right arrow
Author (1)
Michelle M Fernandez
Michelle M Fernandez
Right arrow

Time for action – displaying game messages


Let's set up some win/lose notifications so that we can display these events that occur in game:

  1. Create a new function called alertScreen() and pass two parameters called title and message. Add in a new display object called alertbox and have it transition from xScale and yScale of 0.5 using easing.outExpo:

    function alertScreen(title, message)
      
      alertBox = display.newImage("alertBox.png")
      alertBox.x = 240; alertBox.y = 160
      
      transition.from(alertBox, {time = 500, xScale = 0.5, yScale = 0.5, transition = easing.outExpo})
  2. Store the title parameter in the text object called conditionDisplay:

      conditionDisplay = display.newText(title, 0, 0, "Arial", 38)
      conditionDisplay:setFillColor( 1, 1, 1 )
      conditionDisplay.xScale = 0.5
      conditionDisplay.yScale = 0.5
      conditionDisplay.anchorX = 0.5
      conditionDisplay.x =  display.contentCenterX
      conditionDisplay.y = display.contentCenterY - 15
  3. Store the message parameter in the text object called messageText...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Corona SDK Mobile Game Development: Beginner's Guide
Published in: Mar 2015Publisher: ISBN-13: 9781783559343

Author (1)