User Guide
Table Of Contents
121
into the distance. When the sprites move down the screen, they
are coming closer. However, Scratch does not know that sprites
with a greater y position should be behind other sprites.
The solution is to check the y position of sprites, and use the go
back ? layers block to re-order the sprite layers. You also need to
allow for sprites disappearing when they are defeated, and bear
in mind that the names of enemy sprites may change.
One way to do this is to make a “list” of the sprites that are on
the screen. Lists store strings and numbers, and give each item
in the list a number. The first item is number 1. The second is
number 2, and so on. Where this becomes useful, is that you can
use an item in a list with many of the blocks in Scratch; in
particular, the ? of ? block in the Sensing section of the Blocks
Palette.
First, make a list called Mobs (short for “mobiles”) on the Stage
(so that it is accessible by all sprites).
To add Billy to the Mobs list:
1. In the Sprite List, click Billy.
2. In the Blocks Palette, click Variables.
3. Drag an insert ? at ? of ? block over to the Scripts
Area and snap it into position between the when I
receive Level1 block and the show block.
4. On the insert ? at ? of ? block, click the first box and
then type Billy.
5. Click the second box and then type 1.
6. Click the third box and then click Mobs.
Do the same for the Williams1 sprite:
1. In the Sprite List, click Williams1.
2. In the Blocks Palette, click Variables.
3. Drag an insert ? at ? of ? block over to the Scripts
Area and snap it into position between the when I
receive Spawn1 block and the show block.