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

2.04 Grow to full-size

You will make the dragonfly grow when it eats a fly, and stop if it reaches full-size.

The fly knows that it has been eaten, and now the Dragonfly needs to know so that it grows.

When you need to let another sprite know that something has happened, you can use a broadcast block as you did in Broadcasting spells.

Add a broadcast block to the Insect sprite with new message food:

The Dragonfly sprite needs to grow when it receives the food message.

Select the Dragonfly sprite and add this script:

Add the Chomp sound to the dragonfly and start it when an insect gets eaten:

Test: Run your project to test the dragonfly grows and makes a chomp sound when it eats a fly.

When the dragonfly reaches its full size, the game will congratulate you and stop.

Add an if block.

The dragonfly is full-size when the size = 100%. First, add an = operator into the hexagon-shaped input:

Finish building the condition by adding a built-in size variable and type the value 100:

Add blocks so that if the condition is true then the dragonfly will broadcast an ‘end’ message and say I got to full size!

Finally, add a stop all block to stop the other dragonfly scripts:

At the moment, the fly still moves after the project has ended. Add this script to the Insect sprite.

Test: Click the green flag and keep eating flies until your dragonfly reaches full-size.

×
×

Cart