3.5.4 Event timing
The Timer block is a sensing block that reports the amount of time since the project was loaded or the timer was last reset. This block is almost always used with the Reset Timer block. The timer must be reset at the beginning of a project for the Timer block to hold the right value.
This block can be displayed as a Stage monitor, though it will only display intervals of 0.1. This value can be made more precise by making a script that constantly sets a variable to the timer.
Figure 98: Event Timing
In this example, we are showing how you can set a timer to measure how much time a certain activity or a game took to be completed. We had to set an event first and we said that when you click the space key, the timer will be set to 0 and then wait for a second to start timing forever.
If you want to set a time each event should last, you need to set the timer and give it the number of seconds you want the event or the game to last.
Figure 99: Timing reminder setting blocks
When you click on the green flag, the timer is going to be set to 10 seconds and then wait one second and start deducting one second from the set time.
You can also set a reminder of the time and stop the game all the event.
Figure 100: Timing reminder
We have added a reminder that when the time value reaches 1 minute, the cat is going to tell the player that there is only one-minute remaining. Other actions are also possible, such as stopping the game. The important thing is to know That the timer can trigger actions on a certain value.
Figure 101: A scenario of stopping all activities instead of waiting
Look at Figure 101. We have added another controller that is going to stop everything when the timer reaches to 1 and wait for 1 second.