How to set the timing of actions in Scratch

Share this!

Liam has been learning how to add timing to his code in Scratch recently. While working on his animation of a volcanic eruption, he discovered that some of his sequences were happening way too fast. Understanding timing in Scratch is super useful, because it controls when each Sprite appears, and the delay between each action they undertake on-screen. For the volcano, Liam needed to control several actions:

  • how fast the lava moved
  • the length of delay between each label appearing
  • make sure the ash cloud didn’t appear too early

Timing can be inserted wherever it’s required within the code, but a couple of key places are at the beginning of a code sequence, or embedded in a loop.

Set ‘wait times’ before actions commence

To set a ‘wait time’, add a ‘wait’ instruction at or near the start of the sequence. Liam used this to delay the ash cloud of his volcanic eruption until the lava was well underway. The orange line beneath the starting condition shows this. By inserting the instruction at the top, no further action can take place in this sequence until the 3 seconds has elapsed.

Code for the ash cloud Sprite, with a delay instruction
Code for the ash cloud Sprite, with a delay instruction

Control the interval between Sprites’ costume changes

When Sprites have several costume changes, you don’t necessarily want each one appearing straight away. This was the case in the volcanic eruption project, with both the lava and the labels.

The lava needed to expand, spill over, and extend down the sides of the volcano. For the labels, Liam wanted to allow enough time for viewers to read each label on the volcano before the next one appeared. To achieve both of these, he introduced a ‘wait’ instruction, embedded inside the loop. In this way, there is a delay after every costume change which can be customised for each Sprite.

Coding in Scratch telling the sprite to change costume
Code for the lava Sprite

Where to find the timing block in Scratch

Hop into your code menus in Scratch, on the left-hand side. The orange-labelled menu is called ‘Control, You’ll find an option there that looks like this:

Wait one second

As with other blocks, drag it into the code where you want it, and overtype the ‘1’ with the length of delay you’re looking for.

Other posts you might like:

Share this!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *