Step 10: Player Eats Apple Code 1

Goal:


Let’s now set up code that will run when the player eats the apple.

We will be using a forever block and IF block to constantly check to see if the player has touched an apple sprite.

We need to do this forever because not only do we not know when they will touch the first apple but we also want to make sure they can touch all the apples.

Steps:

  1. From Events place a when green flag click block.
  2. From Control, place a forever block.
  3. From Control, place an IF block.

Code: