Creating a Retro Game Over Behavior

Three live’s and it’s all over… But currently, our Spawn Manager stops and our Player gets destroyed. Leaving us just looking into space. Let’s create more UI to better show that it’s Game Over.Once again, let’s add a Text component to our Canvas, and …


This content originally appeared on Level Up Coding - Medium and was authored by Calum Slee

Three live’s and it’s all over… But currently, our Spawn Manager stops and our Player gets destroyed. Leaving us just looking into space. Let’s create more UI to better show that it’s Game Over.

Once again, let’s add a Text component to our Canvas, and position it as desired.

We only want this to appear when it’s actually Game Over time, so let’s disable it. Now within our UI Manager script, it’s also good practice to make sure it’s disabled at the start of the game. Let’s create a variable to store the Text object and we can then do the following in our Start method.

Now, we could create another public method for the Player to call when Lives is equal to 0. But we are already sending this variable to the UI Manager for our live’s sprites. So let’s use an if statement to check what that value is and then call a private method for our game over functions.

Within the GameOver method, we could now simply set the game over text to active. But we want more of a retro flicker. To do so, we can use a Coroutine and a while loop.

With this, every 0.5 seconds the Game Over text will appear then disappear.


Creating a Retro Game Over Behavior was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Level Up Coding - Medium and was authored by Calum Slee


Print Share Comment Cite Upload Translate Updates
APA

Calum Slee | Sciencx (2021-05-10T23:55:24+00:00) Creating a Retro Game Over Behavior. Retrieved from https://www.scien.cx/2021/05/10/creating-a-retro-game-over-behavior/

MLA
" » Creating a Retro Game Over Behavior." Calum Slee | Sciencx - Monday May 10, 2021, https://www.scien.cx/2021/05/10/creating-a-retro-game-over-behavior/
HARVARD
Calum Slee | Sciencx Monday May 10, 2021 » Creating a Retro Game Over Behavior., viewed ,<https://www.scien.cx/2021/05/10/creating-a-retro-game-over-behavior/>
VANCOUVER
Calum Slee | Sciencx - » Creating a Retro Game Over Behavior. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/10/creating-a-retro-game-over-behavior/
CHICAGO
" » Creating a Retro Game Over Behavior." Calum Slee | Sciencx - Accessed . https://www.scien.cx/2021/05/10/creating-a-retro-game-over-behavior/
IEEE
" » Creating a Retro Game Over Behavior." Calum Slee | Sciencx [Online]. Available: https://www.scien.cx/2021/05/10/creating-a-retro-game-over-behavior/. [Accessed: ]
rf:citation
» Creating a Retro Game Over Behavior | Calum Slee | Sciencx | https://www.scien.cx/2021/05/10/creating-a-retro-game-over-behavior/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.