Whens

A ‘When’ is a block that triggers when happens to an object or to the iPad.

This might actually be a familiar concept! Here are some examples that you might encounter in real life:

  • WHEN it is 7 am, your alarm rings.
  • WHEN you are hungry, you eat a packet of chips.
  • WHEN it is 9 pm, go to sleep.

On Hopscotch, there are ‘Whens’ for events that happen on your iPad/iPhone.

  • WHEN the iPad is shaken, play a pop sound.
  • WHEN the up arrow is pressed, make the character jump.
  • WHEN the score is less than 0, display ‘game over’.

To add a ‘When’ to an object, tap the object, then tap “Add code” or “See code.” Your code will run in Play mode. All the code inside the ‘When’ will run while it is triggered. Once you’ve added a When, the keyboard will change to code blocks. If it doesn’t pop up, you can tap inside the ‘When’ to trigger the code block keyboard.

The keyboard at the bottom of the screen is the Whens keyboard. It’s broken into 3 sections: iPad, Collisions, and Conditionals:

Still need help? Contact Us Contact Us