User Guide
Table Of Contents
111
position before the forever block in the when I
receive Level1 script.
2. On the show variable block, click the down arrow
and then click Score.
3. From the Blocks Palette, drag a show variable
block over to the Scripts Area and snap it into
position underneath the previous block.
4. On the show variable block, click the down arrow
and then click Lives.
5.4 Collision Detection
To prevent the player sprite from moving through walls and into
areas that it is not supposed to move, you can use what
Scratchers call a “wall-sensing sprite”.
This “ghost” sprite is invisible and moves ahead of the player
sprite. When the player presses an arrow key on the keyboard,
the ghost sprite moves. If it collides with a wall, or an area that
the player sprite is not supposed to go, then it moves back to its
previous position. If it does not collide with a wall, it tells the
player sprite to move to the same location.
To make this work, create five new sprites (“masks”) – one for
each of the five backgrounds. These new sprites are also
invisible, but their costume shows the areas that the player sprite
cannot move. The areas in which the player sprite can move are
transparent.
You can create these masks in any image editor, but you can also
do this using Scratch’s built-in tools.
To create the mask for the first background sprite, L1M1:
1. In the Sprite List, right-click L1M1 and then click
duplicate.
2. Click the new sprite and then rename it ML1M1.