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