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 – building bricks


The bricks are the last of the game objects we need to add in for this application. We'll be creating two different levels for this game. Each one will have a different brick layout from the other:

  1. We're going to create the function for the first level. Let's create a new function, gameLevel1(). We will also set currentLevel to 1 since the application begins at level 1. Then, we'll add in the bricks display group and set it as toFront() so that it appears in front of the game background:

    function gameLevel1()
    
      currentLevel = 1
    
      bricks:toFront()

    The method object:toFront() moves the target object to the visual front of its parent group (object.parent). In this case, we are setting the bricks group to appear as the front-most display group during game play so that it appears in front of the background image.

  2. Next, add some local variables that will show how many rows and columns of bricks will be displayed on screen and where each brick will be placed in the...