Game Over question. Resetting to a certain scene and not entire game.
gulleyryan7
Member, PRO Posts: 10
In my game I'm having multiple areas. Each area holds 5 levels. How can I make it, where if the player runs out of lives in a certain level within an area, he will respawn at the beginning of that area?
For Example: If player runs out of lives in Area 3 Level 4, he will restart the game but in Area 3 Level 1.
Answers
On the Level 1 scene of each area, increment the value of an integer game attribute (e.g. game.currentArea) by 1. So on the Area 3 Level 1 scene, game.currentArea would be changed to 3, for example. Then when the player runs out of lives, change the scene to level 1 of that area based on the value of game.currentArea. Depending on how your scenes are arranged and the number of levels per area (whether or not every area has the same number of levels), you may be able to use a mathematical expression to determine which scene is level 1 for the current area or you may need one rule per area (e.g. If game.currentArea=3 then change scene [Area 3 Level 1 scene]).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Ok I'm understanding the concept of the game.currentArea variable but I'm not sure how to implement that to when the player runs out of lives. How do I tell the game to identify: if I die on game.currentArea3 then change scene to Area 3 Level 1?
As of right now, I have it like this:
If players.lives = 0
if game.currentArea = 2
then:
Reset Game
Change Scene to Area 2 Level 1
However, when this happens it just resets the game at Area 1 Level 1. I need it to reset the actors and variables in the game but take me back to Area 2 Level 1 when that happens.
Each scene has a variable for game.currentArea where the value equals a number for the Area that scene is on.
My question has not yet been answered why was this flagged as "answered"?
Have you tried just using reset scene instead of game?
If i do the reset scene it won't reset the necessary variables that reset game does.
As in my players lives. So it will just keep starting that scene over with 1 life.
How many attributes do you have to reset? You could do it quite simply if you only have a few.
Pretty much just the lives attribute. I'll just go in and manually reset that with change attribute.
Yea, that's not to hard. Make it like this(you'll need a few rules): if game.currentArea = 1 &
if game.Life = 0 :do: spawn actor at the area 1 beginning coordinates. Then: if game.currentArea = 2 & game.Life = 0 :do: spawn actor at area 2 beginning coordinates and so on.Then just add a change attribute (in no rules or anything, just a lone change attribute in your player actor) that says change attribute game.Life :to: 3 or whatever. Also in your destroy actor rule make sure you put a timer that says After 0.01 :do: destroy. That way the life can reset before it is destroyed and every time it is spawned the life will reset. Phew I hope that makes sense
My instructions were to increment game.currentArea each time the player starts a new area (e.g. Area 3 Level 1). So if the player is on Area 3 Level 4, the rule would change scene to Area 3 Level 1 because game.currentArea is 3.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User