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 – adding game objects


Let's add in the display objects the player will see while in game play:

  1. After the loadGame() function, we're going to create another function that will display all our game objects on screen. The following lines will display the art assets that were created for this tutorial:

    function addGameScreen()
    
      background = display.newImage("bg.png", 0, 0, true )
      background.x = _W 
      background.y = _H
      
      paddle = display.newImage("paddle.png")
      paddle.x = 240; paddle.y = 300
      paddle.name = "paddle"
      
      ball = display.newImage("ball.png")
      ball.x = 240; ball.y = 290
      ball.name = "ball"
  2. Next, we'll add in the text that will display the score and level number during the game:

      scoreText = display.newText("Score:", 25, 10, "Arial", 14)
      scoreText:setFillColor( 1, 1, 1 )
    
      scoreNum = display.newText("0", 54, 10, "Arial", 14)
      scoreNum: setFillColor( 1, 1, 1 )
    
      levelText = display.newText("Level:", 440, 10, "Arial", 14)
      levelText:setFillColor( 1, 1,...