Game conditions are the rules that dictate a victory or loss. This game will include the following conditions:
Lives
Timer
Score
The player will start the game with three lives. Each time Spongy comes into contact with the acid blobs, the player will lose a life.
Should the player lose all three lives, then the game is over. To stop gameplay, we use the following line:
Time.timeScale = 0;
It is also useful for not only pausing and resuming, but also for slow and fast forward effects.
Add the following script to Spongy.js
:
var lives:int = 3; function OnCollisionEnter2D(other:Collision2D) { if(other.gameObject.name=="Acid(Clone)") { lives = lives - 1; if (lives == 0) { Time.timeScale = 0; } } //will add score here }