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

#1 2007-09-18 13:41:35

BLUEBOY
Scratcher
Registered: 2007-09-18
Posts: 1

How do you stop the timer?

I am during making my first game and i wish to make it a endurance game-i have made it all but how do u stop the timer?

please post how to stop it and what things you've got to use<timer>

Offline

 

#2 2007-09-18 13:58:01

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: How do you stop the timer?

Hi Blueboy.
[blocks]<reset timer>[/blocks]
will revert the timer to 0.

If you want the timer to be able to pause and resume, I would rather use a timed variable loop instead of the timer block.

Something like:

   set playtime to 0
   forever if running=1
      wait 1 sec
      change playtime by 1
   end

   when key space pressed
   set running to 0

hope that helps.

Last edited by Jens (2007-09-18 14:00:22)


Jens Mönig

Offline

 

#3 2007-09-18 19:27:13

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: How do you stop the timer?

You can also record the timer at various times to time just selected intervals.

For example, if you want to time the time between space clicks:

wait until key space down
set old_time to timer
wait until not key space down
wait until key space down
say timer - old_time

Offline

 

#4 2007-09-19 03:27:42

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: How do you stop the timer?

indeed, once again Kevin's suggestion is the simpler and better one ;-)


Jens Mönig

Offline

 

Board footer