play again button
So I have a high score scene at the end of all my levels and each of the levels go there when the player dies. How do I get the scene to change to the last scene entered when I press the button? (Not the last one in the scene order but the one the player was on last)
Best Answer
-
tatiang Posts: 11,949
For this method to work, all of your level scenes have to be in order and you'll need to figure out an offset value. The offset value is simply the difference between the "level 1" scene's location and the first scene in your game. For example, if your scenes in the scene tab are in this order: main menu-->instructions-->pause-->highscore-->level 1-->level 2-->level 3, then your offset value is 4 because the "level 1" scene is actually the 5th scene and therefore to change to that scene you'd use the mathematical expression [level]+4. To change to the "level 2" scene, the expression would be 2+4=6, etc.
As for the rules, when each level starts, change attribute game.level to game.level+1. Then, in the play again actor, have a rule that says When Touch is Pressed --> Change Scene to [at index] game.level+4 (or whatever your offset value is).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Answers
Do you mean previous scene?
not exactly, when I use that it goes to the previous slide in the slide in the slide order, I want it to go to the last slide the player was on (this is the level the player died on)
Set up an attribute to keep track of what level the player is on then make a rule that uses that attribute to decide which level to go to. So -
Button is down and attribute game.whichlevel is 3 ... go to level 3
Alright, I think I know what to do. Thanks to everyone!