Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » when a timer gets to 0 how do you make it switch backdrop when it happens
- scratchman3210
-
1 post
when a timer gets to 0 how do you make it switch backdrop when it happens
hi!
I need serious help I am trying to make a game I want to put a timer on it and when the timer reaches 0 I want it to switch backdrop
I put in when green flag clicked if time =0 switch to backdrop 3
but it dos not work please help me
I need serious help I am trying to make a game I want to put a timer on it and when the timer reaches 0 I want it to switch backdrop
I put in when green flag clicked if time =0 switch to backdrop 3
but it dos not work please help me
- drmcw
-
1000+ posts
when a timer gets to 0 how do you make it switch backdrop when it happens
You could use the wait block instead, so wait 10 seconds then change backdrop?
If you're using the timer in sensing then it doesn't count down it counts up. So if you wanted to wait 10 seconds you'd use;
reset timer
wait until timer > 10
switch to backdrop 3
If you really want to make a count down timer then you need to use a variable and a simple way to achieve this is;
when gf clicked
set countdown to 10
forever
wait 1 second
change countdown by -1
If you don't want it to countdown forever then change that block to whatever you need.
If you're using the timer in sensing then it doesn't count down it counts up. So if you wanted to wait 10 seconds you'd use;
reset timer
wait until timer > 10
switch to backdrop 3
If you really want to make a count down timer then you need to use a variable and a simple way to achieve this is;
when gf clicked
set countdown to 10
forever
wait 1 second
change countdown by -1
If you don't want it to countdown forever then change that block to whatever you need.
Last edited by drmcw (July 15, 2013 07:36:51)
- turkey3
-
1000+ posts
when a timer gets to 0 how do you make it switch backdrop when it happens
Here's the problem with your script. You have
The problem is the if. This script does not constantly sense when the timer = 0. It only senses if it is once and then the script ends. It doesn't repeatedly check if the condition is true. What you can do if put a forever loop around the blocks to make it always check the condition, but the best way to go is to have
To countdown you can use the method above in that post.
when green flag clicked
if <(timer) = (0)>
switch backdrop to [backdrop 2]
when green flag clicked
wait until <(timer = (0)>
switch backdrop to [backdrop 2]
Last edited by turkey3 (July 15, 2013 13:12:04)
- programma07
-
36 posts
when a timer gets to 0 how do you make it switch backdrop when it happens
Try hi!
I need serious help I am trying to make a game I want to put a timer on it and when the timer reaches 0 I want it to switch backdrop
I put in when green flag clicked if time =0 switch to backdrop 3
but it dos not work please help me
- LucaR10
-
100+ posts
when a timer gets to 0 how do you make it switch backdrop when it happens
Hope this helped.
- deck26
-
1000+ posts
when a timer gets to 0 how do you make it switch backdrop when it happens
Please don't use a forever loop for this. It's unnecessary and you risk finding the forever loop is then running at a later stage in your project and still changing the background when you don't want it to. A wait until is much better, giving you much more control and saving you having to stop the script once it has done its work.
- _Foxy_Gaming_
-
1 post
when a timer gets to 0 how do you make it switch backdrop when it happens
I think LucaR10 helped ME the most! But thanks all of you! I'm just a 10 year old with good grammar that's new to coding!
You guys rock! Thx!
*Foxy Gaming
You guys rock! Thx!
*Foxy Gaming
- WolfCat67
-
1000+ posts
when a timer gets to 0 how do you make it switch backdrop when it happens
You could use this:

This will make it so that every second the timer will go down by 1 from the original number, and will keep doing so until it's 0 at which point the background will change.

- WolfCat67
-
1000+ posts
when a timer gets to 0 how do you make it switch backdrop when it happens
Oh, I just realized that this was a necroposted topic. I need to be more careful! Reporting…
- Harakou
-
1000+ posts
when a timer gets to 0 how do you make it switch backdrop when it happens
Closed as resolved. Thanks for the advice everyone, but please check the date before replying and make sure that the thread is still relevant. 

- Discussion Forums
- » Help with Scripts
-
» when a timer gets to 0 how do you make it switch backdrop when it happens