Ending the game
This is a high score game so technically there is no way to BEAT the game.
This is a high score game so technically there is no way to BEAT the game.
The game ends
The game ends
once the fruit has piled up to the top of the screen
once the fruit has piled up to the top of the screen
and is overlapping the container boundary
and is overlapping the container boundary
Add a new function to the the functions group Call it gameOver
Add a new function to the the functions group Call it gameOver
Create a sub-event and In the function disable physics on all the fruit
Create a sub-event and In the function disable physics on all the fruit
When the game is over we want to gently fade to black and display the players score.
When the game is over we want to gently fade to black and display the players score.
Add a new tiled background to the Temp layout.
Add a new tiled background to the Temp layout.
Call it Fader
Call it Fader
Use the Fader image file or fill the rectangle with black.
Use the Fader image file or fill the rectangle with black.
Add the Tween behaviour
Add the Tween behaviour
Set the Size to 1080 x 1920
Set the Size to 1080 x 1920
Set the Opacity to 0
Set the Opacity to 0
To display the Game Over message and the score
To display the Game Over message and the score
Add a new Text Object to the Temp layout
Add a new Text Object to the Temp layout
Call it TextGameOver
Call it TextGameOver
Set the properties as shown
Set the properties as shown
Add the Tween behaviour to TextGameOver
Add the Tween behaviour to TextGameOver
For the Text itself, set it using BBCode (an older form of HTML)
For the Text itself, set it using BBCode (an older form of HTML)
Final display properties for the text are shown:
Final display properties for the text are shown:
In the gameOver function we can now show the fader, the game over message and the score
In the gameOver function we can now show the fader, the game over message and the score
The Game Over function needs to be called somewhere
The Game Over function needs to be called somewhere
We will check if the fruit is overlapping the top of the screen. If it is, and the fruit is active, then we call the game over function.
We will check if the fruit is overlapping the top of the screen. If it is, and the fruit is active, then we call the game over function.