There are 3 scenes in my game.
- MainMenu - there is a start game button, when click it, it goes to next scene.
- Loading - it loads the 3rd scene.
- Game - the game
In the Game, there is a script to control character lives.
here is the code:
function Update ()
{
switch(LIVES)
{
case 3:
guiTexture.texture = health3;
break;
case 2:
guiTexture.texture = health2;
break;
case 1:
guiTexture.texture = health1;
break;
case 0:
Application.LoadLevel ("MainMenu");
break;
}
if(playerScore >= 100)
{
Application.LoadLevel ("MainMenu");
}
}
Either Character got 100 score to win or lose 3 lives to die, it returns to MainMenu.
Then, I click on Play Game button in MainMenu, it goes to loading scene and Game scene.
However, it quickly returns back to MainMenu again.
So, how should I code the Application.LoadLevel properly?
In fact, I would like to build a scene called “PlayAgain”, after character dies, then it will go to that scene to ask whether user wants to play it again.
Is that logic correct? and what is the usual practice to code it?