This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-03-21 13:25:33

jpsrolls
New Scratcher
Registered: 2010-12-09
Posts: 17

Use of the timer

One of my students is having a sprite dance to music she imported.  The music is rather long, and she wants it to stop when the sprite finishes the dance.  I thought use of the timer would be a good idea.  She would time the program until the sprite finished the dance.  It turned out to be 30 seconds into the program that the sprite stopped dancing.  We then tried a repeat until loop, but it's not working.  Could you help us?  Here is part of the code:




when gf clicked
repeat until timer = 30   
wait 0.5 sec
switch to costume backbend
wait 0.5 sec
switch to costume kneeup
wait 0.5 sec
switch to costume kneeback
wait 0.5 sec
switch to costume kickfoot
wait 0.5 sec

Offline

 

#2 2012-03-21 13:30:47

jpsrolls
New Scratcher
Registered: 2010-12-09
Posts: 17

Re: Use of the timer

Trying to submit code agian.

when gf clicked
repeat until timer = 30   
wait 0.5 sec
switch to costume backbend
wait 0.5 sec
switch to costume kneeup
wait 0.5 sec
switch to costume kneeback
wait 0.5 sec
switch to costume kickfoot
wait 0.5 sec

Offline

 

#3 2012-03-21 13:30:48

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: Use of the timer

The timer is pretty fast. If you use timer = 30, the timer will pass 30 too quickly, so it doesn't sense that the timer reaching 30.

Use this instead:

<not <(timer) < [30]>>
This will repeat the script only if 30 or more seconds have not passed yet.

Offline

 

#4 2012-03-21 15:27:43

jpsrolls
New Scratcher
Registered: 2010-12-09
Posts: 17

Re: Use of the timer

This is working well.  Thanks so much!

Offline

 

#5 2012-03-21 15:36:34

turkey3
Scratcher
Registered: 2011-12-04
Posts: 500+

Re: Use of the timer

rdococ wrote:

The timer is pretty fast. If you use timer = 30, the timer will pass 30 too quickly, so it doesn't sense that the timer reaching 30.

Use this instead:

<not <(timer) < [30]>>
This will repeat the script only if 30 or more seconds have not passed yet.

Or

<(timer) > [30]>

Last edited by turkey3 (2012-03-21 15:37:03)

Offline

 

Board footer