COLLISION EVENT: Using the collision event, you can detect when two sprites are touching.

When a collision event is triggered by sprites touching, it is automatically passed each sprite as parameters. The sprite parameter refers to the sprite in the event handler. hit_sprite refers to any other sprite that touches sprite.

  • Click Run and see what happens. That was unexpected! Let's change the event to the shark's advantage.
  • Switch the assignment of all actions in the event from hit_sprite to sprite and from sprite to hit_sprite.

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)