Previous: Ease of Building UI Elements in Unity
Now we got lives count sprite and player destroy-function, it is time to make a game over sprite.
Same as score text, create another text game object of game over. In the text component, change the Horizontal Overflow and Vertical Overflow to Overflow.
Then add a variable of game over text and some lines in the method that dealing the lives sprite.
We can hide the game over text at void Start() when game start. And set it active in the method.
Press Play and the game over sprite will appear when the lives is 0.
We can make this game over sprite present as retro style with flicker effect.
This effect would easily present by using coroutine.
Create a IEnumerator to repeat this effect.
In this coroutine, we will get the text component and turn it on & off every 0.5 second. Then we need to call it in under the game over sprite appear.
The you should get the flicker effect.