Working with a Timer

Another pair of sensing code blocks that you need to become familiar with is shown in Figure 6.11. These code blocks provide the ability to enable and work with Scratch’s built-in timer.

Figure 6.11. These sensing blocks provide the ability to enable and use a timer within your Scratch application.


The first code block resets the timer back to its default value of zero, and the second code block retrieves a number specifying how many seconds have passed since the timer started running. Using Scratch’s timer, you can control the pace of animation and the operation of your Scratch applications. For example, you would need to use these controls to keep track of time when players are given a certain amount of time in which to make a move.

The following example demonstrates how to use both of these timer code blocks to create a script that repeatedly plays an audio file for five seconds.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.63.165