From Test-Scratch-Wiki
This article or section needs additional citations for verification. Its information may not be accurate. Editors can help by adding references. |
The Timer is a feature in Scratch that will record how much time, in seconds, have passed since the last time a project was opened or the timer was reset.
The timer is extremely accurate and the value itself is not affected by lag. The timer will accumulate only one second of error after approximately 46 minutes.[citation needed]
Related Blocks
The timer is associated with two blocks, both found in the Sensing category:
- Reset Timer: Sets the timer's value to 0.0
- Timer: The stage monitor and reporter block of the value
How it works
The timer works in the following ways:
- Continuously counts upwards by tenths of seconds
- Cannot be paused or stopped (that would imply pausing or stopping the flow of time itself)
- Shows seconds, not minutes or more
— even when the current value is longer than sixty seconds
- Resets only when a project is opened inside Scratch or by execution of the Reset Timer block
- Continues even when its project stops running
Other Method
A lot of Scratchers prefer to use a variable instead of the timer, because the timer does not stop when the stop button is pressed. This method, however, is just over 7% slower than the real timer. [citation needed]
when gf clicked set [timer v] to (0) forever wait (1) secs change [timer v] by (1)
The accuracy can be improved slightly by reducing the wait by a few milliseconds, for example, to 0.99 seconds.
Example Uses
The timer is commonly used in projects that require a clock of some sort, such as racing projects. Other uses include:
- Using time duration in one sprite one script projects without pausing the script
- Checking how long a level took to complete
- A lag detector for a game.
- A turbo mode detector.