Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to stop the timer when you win?
- kingdanny54
-
9 posts
How to stop the timer when you win?
In my game, https://scratch.mit.edu/projects/73906534/ , I made it so that when you win,you go to the win page, the timer is supposed to stop. I tried to broadcast to the sprite with the timer to stop by tirning on the stop script, but that does not work. Can someone help me?
- deck26
-
1000+ posts
How to stop the timer when you win?
You still have a repeat 20 loop telling the variable to show and changing its value. You need to tell that script to stop - perhaps with
- Zekrom01
-
1000+ posts
How to stop the timer when you win?
Unfortunately, I don't think it's possible to stop the timer with just one block. However, you should consider trying this:
This will “reset” the timer so it's always at 0. However, there is no possible way to hide the timer itself, though.
- kingdanny54
-
9 posts
How to stop the timer when you win?
Actually Zekrom, It wasn't a timer. It is a variable.
Last edited by kingdanny54 (Aug. 24, 2015 17:09:50)
- deck26
-
1000+ posts
How to stop the timer when you win?
I don't think they're using the built-in timer; they're using their own coded timer. Unfortunately, I don't think it's possible to stop the timer with just one block. However, you should consider trying this:This will “reset” the timer so it's always at 0. However, there is no possible way to hide the timer itself, though.
- kingdanny54
-
9 posts
How to stop the timer when you win?
But i'm using a variable as a timer. How do I stop that?
- Zekrom01
-
1000+ posts
How to stop the timer when you win?
What do you mean? like they used a sprite for it?I don't think they're using the built-in timer; they're using their own coded timer. Unfortunately, I don't think it's possible to stop the timer with just one block. However, you should consider trying this:This will “reset” the timer so it's always at 0. However, there is no possible way to hide the timer itself, though.
- koda1956
-
100+ posts
How to stop the timer when you win?
just use something like this But i'm using a variable as a timer. How do I stop that?
- deck26
-
1000+ posts
How to stop the timer when you win?
No, a variable, changing by 1 every second in a loop.What do you mean? like they used a sprite for it?I don't think they're using the built-in timer; they're using their own coded timer. Unfortunately, I don't think it's possible to stop the timer with just one block. However, you should consider trying this:This will “reset” the timer so it's always at 0. However, there is no possible way to hide the timer itself, though.
- koda1956
-
100+ posts
How to stop the timer when you win?
when you win, set win to yes. when the variable win is at yes, it stops the timer variable.just use something like this But i'm using a variable as a timer. How do I stop that?
- deck26
-
1000+ posts
How to stop the timer when you win?
Why? I'm so confused…
]
@koda1956's suggestion is OK but you might not want the timer to start immediately with the green flag - perhaps a broadcast when you're ready to start the timer. I suspect you also want the timer to decide when the game is lost.
- Zekrom01
-
1000+ posts
How to stop the timer when you win?
Oh. Ok.No, a variable, changing by 1 every second in a loop.What do you mean? like they used a sprite for it?I don't think they're using the built-in timer; they're using their own coded timer. Unfortunately, I don't think it's possible to stop the timer with just one block. However, you should consider trying this:This will “reset” the timer so it's always at 0. However, there is no possible way to hide the timer itself, though.
In that case, make a variable called win. In the beginning, set it to zero, then if you win, set it to 1.
Like this:
I hope this works…
Last edited by Zekrom01 (Aug. 24, 2015 17:32:19)
- monstermash3
-
1000+ posts
How to stop the timer when you win?
It is impossible to stop the actual timer. With two variables (the “timer” being the timer):
- kingdanny54
-
9 posts
How to stop the timer when you win?
It is impossible to stop the actual timer. With two variables (the “timer” being the timer):
- deck26
-
1000+ posts
How to stop the timer when you win?
Let's see if I can help. /so confused
I suspect you're seeing the different solutions and that's not helping. There's always multiple ways of coding things and I'm not going to compare the different solutions but obviously I prefer to talk about my own offering.
So the key is the timer will continue until you tell it to stop and what you had was the condition where you'd detected a winner but the timer was still running. So somehow, when the winner is detected the timer needs to stop.
There is a built-in timer (the blue timer block) which is more accurate than using your own code but it's probably overkill and causing confusion in your case. So let's ignore that.
So my solution as shown earlier
** you may prefer to use time = 20 in the repeat until conditions
Any questions?
- monstermash3
-
1000+ posts
How to stop the timer when you win?
(sorry I forgot to close my tag, closing it now)Uh? It is impossible to stop the actual timer. With two variables (the “timer” being the timer):
See my project Drawing Project 1.6 for an example.
- Discussion Forums
- » Help with Scripts
-
» How to stop the timer when you win?