SCRATCH GOLD II
SCRATCH GOLD I
2 of 3

5.03 Lightning bolts

Now you are going to give the spaceship the ability to fire lightning bolts!

Add the Lightning sprite from the Scratch library.

Click on Choose a Sprite to open the Sprite Library:

The 'Choose a Sprite' icon highlighted.

You can search for a sprite, or browse for one by category. Click on a sprite to add it to your project.

The Sprite Library.

When the game starts, the Lightning sprite should be hidden until the spaceship fires its laser cannons.

Add this code to the Lightning sprite:

lightning sprite

At the moment, the lightning bolt is really big compared to the spaceship!

Below the code that the Lightning sprite already has, add some blocks to make the sprite smaller and to turn it upside down.

lightning sprite

Now it looks like it fires pointy end–first out of the spaceship.

Add some new code to the Spaceship sprite to create a new clone of the lightning bolt if the space key is pressed.

Whenever the game creates a Lightning sprite clone, the clone should appear and then move upwards until it reaches the top of the Stage. Then the clone should disappear.

Add this code to the Lightning sprite so that clones of it move upwards until they touch the edge of the Stage, and then they get deleted.

lightning sprite

Press the space key to test whether the lightning bolt moves correctly.

×
×

Cart