Now you are going to give the spaceship the ability to fire lightning bolts!
Add the Lightning
sprite from the Scratch library.
When the game starts, the
sprite should be hidden until the spaceship fires its laser cannons.Lightning
Add this code to the
sprite:Lightning
At the moment, the lightning bolt is really big compared to the spaceship!
Below the code that the
sprite already has, add some blocks to make the sprite smaller and to turn it upside down.Lightning
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
sprite clone, the clone should appear and then move upwards until it reaches the top of the Stage. Then the clone should disappear.Lightning
Add this code to the
sprite so that clones of it move upwards until they touch the edge of the Stage, and then they get deleted.Lightning
Press the space key to test whether the lightning bolt moves correctly.