Put a <stop all>[/blocks] script in the <if><touching color[ red[/blocks] block.
Last edited by hmnwilson (2008-10-23 23:14:40)
Offline
The stopall is a good idea -- if you don't mind the program stopping at that point.
As you've found, you can't stop the timer when a program is running.
You could have another sprite appear on top of it -- for example, a sprite that says "Game Over."
OR, If you want the timer value to stay on the screen, you could also create a variable. "hide variable" when green flag clicked, then when the head hits the red bar, "set variable" to the timer value, and then" show variable" (so it covers the running timer). Yeah, probably unduly complicated (and requires Scratch 1.3)
Offline
I usually just build my own timer using a variable that I update every second in a loop. The loop tests on a flag variable to see if it should continue looping. That way it can be turned on or off by changing the value of the flag variable.
Offline
natalie wrote:
You could have another sprite appear on top of it -- for example, a sprite that says "Game Over."
Okay, I decided to go with this since it seems the simplest solution. Just one question, I made the 'Game Over' sprite, positioned it over the timer and I'm using
<when green flag clicked>
and
<hide>
blocks to keep the timer visable while the game is in play. How do I cue the 'Game Over' sprite to appear over the timer when the head contacts the red bar?
Offline
nytram wrote:
natalie wrote:
You could have another sprite appear on top of it -- for example, a sprite that says "Game Over."
Okay, I decided to go with this since it seems the simplest solution. Just one question, I made the 'Game Over' sprite, positioned it over the timer and I'm using
<when green flag clicked>
and
<hide>
blocks to keep the timer visable while the game is in play. How do I cue the 'Game Over' sprite to appear over the timer when the head contacts the red bar?
On the head sprite, set up a script like this:
[blocks]
<when green flag clicked>
<wait until><touching color[ red
<broadcast[ Show Game Over
[/blocks]
And on the Game Over sprite set up a script like this:
[blocks]
<when I receive[ Show Game Over
<show>
[/blocks]
That should do it!
Note that the message "Show Game Over" is something you make up...you can actually use any text you like. When you look at the Broadcast block, you will see "New" as the only option at first, you pick that then type in whatever you want the message to be.
Offline
Paddle2See wrote:
On the head sprite, set up a script like this:
[blocks]
<when green flag clicked>
<wait until><touching color[ red
<broadcast[ Show Game Over
[/blocks]
And on the Game Over sprite set up a script like this:
[blocks]
<when I receive[ Show Game Over
<show>
[/blocks]
That should do it!
Note that the message "Show Game Over" is something you make up...you can actually use any text you like. When you look at the Broadcast block, you will see "New" as the only option at first, you pick that then type in whatever you want the message to be.
Didn't work.
Offline
First, don't worry about a timer. Define a variable "time". When you want the timer to start, use a broadcast "BeginTimer".
[blocks]<when I receive[ start timer
<set{ time }to( 0
<repeat until><touching color[ red
<wait( .01 secsc>
<change{ time }by( .01
<end>
<stop script>[/blocks]
Last edited by legolover (2008-10-25 13:53:06)
Offline
legolover wrote:
First, don't worry about a timer. Define a variable "time". When you want the timer to start, use a broadcast "BeginTimer".
[blocks]<when I receive[ start timer
<set{ time }to( 0
<repeat until><touching color[ red
<wait( .01 secsc>
<change{ time }by( .01
<end>
<stop script>[/blocks]
Thanks. I'll give it a try.
Offline
nytram wrote:
Paddle2See wrote:
Can you share it so I can see why it isn't working?
Yes. Thank you.
![]()
http://scratch.mit.edu/projects/nytram/302013
Okay, I identified a couple of problems in comments on the project. Hopefully they will help.
Offline
Paddle2See wrote:
nytram wrote:
Paddle2See wrote:
Can you share it so I can see why it isn't working?
Yes. Thank you.
![]()
http://scratch.mit.edu/projects/nytram/302013Okay, I identified a couple of problems in comments on the project. Hopefully they will help.
Perfect. Thank you.
Offline
legolover wrote:
First, don't worry about a timer. Define a variable "time". When you want the timer to start, use a broadcast "BeginTimer".
Alternatively, still using a variable called time:
When I recieve "Start Timer"
Reset Timer
Repeat until touching colour red
set "Time"="timer"
Offline