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:
We're going to create the function for the first level. Let's create a new function,
gameLevel1()
. We will also setcurrentLevel
to1
since the application begins at level 1. Then, we'll add in thebricks
display group and set it astoFront()
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 thebricks
group to appear as the front-most display group during game play so that it appears in front of the background image.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...