Scratch Silver III
Scratch Silver II
SCRATCH SILVER I
SCRATCH GOLD III
1 of 3

2.03 A fly to eat

You will add an insect for the dragonfly to eat.

There’s a fly in the Frog 2 sprite that you can use.

Add the Frog 2 sprite to your project. Rename the sprite to Insect:

You only need the fly, not the frog.

Click on the Costumes tab. Click on the fly to select it and click on the Copy icon.

Add a new costume to the sprite using the Paint option:

Click on the Paste icon to paste the sprite into the new costume. Drag the fly to the centre so it lines up with the crosshair.

You can rename your costume Insect and delete the other costumes, as you won’t need those:

Increase the size of the fly so that it’s easier to see and catch:

Click on the Code tab and add a script to make the Insect sprite bounce around:

The if on edge, bounce block checks to see if the sprite has reached the edge of the Stage and points the sprite in a different direction if it has.

You want the Insect sprite to hide if it gets eaten by the Dragonfly sprite.

Add an if block to the Insect sprite’s movement script:

The if has a hexagon-shaped input. This means you can put a condition here.

When the if block runs, Scratch will check the condition. If the condition is ‘true’ then the code inside the if block will run.

You want the insect to hide if it is touching the Dragonfly sprite.

Drag a touching [Dragonfly v] into the if  block. Add a hide block inside the if block.

Test: Test your code and control the dragonfly to eat the fly. The fly should disappear.

The dragonfly won’t get very big if it can only eat one fly!

Add blocks to go to a random position on the Stage, and make your sprite wait for one second then show:

Test: Test that your dragonfly can now eat lots of flies.

Make sure you have added the show block to show at the start.

Tip: You can click the red Stop button above the Stage if you want the dragonfly to be quiet while you add more code.

×
×

Cart