Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
We'll need to create functions that set up the first and second level in the game. If a level needs to be replayed, only the current level the user lost in can be accessed.
changeLevel1(). This will be placed below the updateBall() function:function changeLevel1()
bricks group when the player loses the round and reset them:bricks:removeSelf() bricks.numChildren = 0 bricks = display.newGroup()
alertDisplayGroup:
alertBox:removeEventListener("tap", restart)
alertDisplayGroup:removeSelf()
alertDisplayGroup = nil
ball and paddle position:ball.x = (display.contentWidth * 0.5) - (ball.width * 0.5) ball.y = (paddle.y - paddle.height) - (ball.height * 0.5) -2 paddle.x = display.contentWidth * 0.5