Next level and timer?

Hey guys, I have two questions. The first is, if I have some characters and they are supposed to be destroyed then it goes to the next level, how can I do that? There are still items in the scene but when certain items are destroyed, I want it to move to the next level. Second, how can I add a simple countdown timer to my scene? I don't want the hundredths and thousandths and all that, just a simple 5 4 3 2 1 timer. Thank you
Comments
So first you could have an index attribute for your destroyed actors. And have it increment by 1 each time an actor is destroyed. (Obviously that rule goes just before the command to destroy it). Let's call it game.deadStuff
Then make a real attribute. It could be a scene, game or actor attribute. For now let's say a game attribute: game.timeSnap
So the rule would be:
when game.DeadStuff = 3 (or whatever your number is)
change game.timeSnap to game.time.
And then another rule:
When game.time is equal to or more than game.timeSnap+0.5 (or how ever many seconds you want)
Change scene
P.S it's good practice to make an attribute for the number of seconds, which is 0.5 in the example above. Then it will be easy to modify your game as you go along without having to click around inside every actor typing things in.
For a countdown timer, have a game attribute called CountdownTimer (integer) set to 5. Have an actor with a rule: If game.CountdownTimer>0 then... add a timer behavior "every 1 second" Change Attribute game.CountdownTimer=game.CountdownTimer-1. Add a Display Text behavior with game.CountdownTimer as the expression. If you want the scene to change after 5 seconds, have another rule that says If game.CountdownTimer=0, Change Scene .
I haven't tested the count down timer, so you might have to make it If Game.CountdownTimer<=0, Change Scene <next scene>, but you probably can get the idea of it.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
The 0.5 second timer is there to allow the enemies time to appear/spawn and correctly increase game.Enemy to whatever number it should be. You can use any value... 1 second, 2 seconds, etc. but it needs to be less than however long you think it will take for someone to beat that level. I usually use 0.1 or 0.5 seconds.
The log debugging statements will tell you a little about what's happening if it still isn't working for you. That or just add a Display Text actor with game.Enemy as the value for the text and add it to your scene so you can watch what's happening with that attribute.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User