Discuss Scratch

scratchman3210
New Scratcher
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
drmcw
Scratcher
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.

Last edited by drmcw (July 15, 2013 07:36:51)

turkey3
Scratcher
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
when green flag clicked
if <(timer) = (0)>
switch backdrop to [backdrop 2]
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
when green flag clicked
wait until <(timer = (0)>
switch backdrop to [backdrop 2]
To countdown you can use the method above in that post.

Last edited by turkey3 (July 15, 2013 13:12:04)

programma07
Scratcher
36 posts

when a timer gets to 0 how do you make it switch backdrop when it happens

scratchman3210 wrote:

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
Try

whenclickedforeverif(time)=0thenswitchbackdropto backdrop3
LucaR10
Scratcher
100+ posts

when a timer gets to 0 how do you make it switch backdrop when it happens

whenclickedsettimetoHow many seconds you want foreverifTime= 0thenswitchbackdroptobackdrop 3

whenclickedswitchbackdroptoStarting backdropforeverwait1secschangetimerby-1

Hope this helped.
deck26
Scratcher
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_
Scratcher
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
WolfCat67
Scratcher
1000+ posts

when a timer gets to 0 how do you make it switch backdrop when it happens

You could use this:
whenclickedsetTimetoNumberrepeatuntilTime=0wait0.99secschangeTimeby-1switchbackdroptoBackdrop You Want
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
Scratcher
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
Scratcher
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.

Powered by DjangoBB