Watch the movie
Watch the movie below to see a cannon that shoots. When you press and hold the mouse button, the cannon points in the direction of the mouse cursor. When you press spacebar, the cannon shoots. When you hit the target, the target explodes.
Here’s a picture of the stage background. Notice that the cannon’s mount is part of the stage. Have fun making something similar!
You’ll need 3 sprites: the cannon, the shot, and the target. Make sure that you give your sprites the same names that they have in the picture below:
The target sprite has 2 costumes, like this:
When you create the cannon, it might be helpful to watch the movie below. The movie shows how to set the costume center of the cannon so that it rotates in a realistic way.
When the mouse button is held down, the cannon always points in the direction of the mouse pointer. Can you assemble the commands below to make that happen? You’ll need to change the order of the commands and the numbers or options!
The script for the shot sprite requires a few steps.
When the green flag is clicked, the shot sprite hides. Can you add the appropriate command to the shot script?
When the spacebar is pressed, the shot sprite…
- goes to the cannon
- points in the direction of the cannon
- shows itself
- moves continuously until it reaches either the edge of the screen or the target
- hides again
Step c requires adding one, simple command. Can you find it and add it?
Step e requires adding one, simple command. Can you find it and add it?
Here’s the last step! When the shot sprite reaches the target, the target should explode! Here are the commands you’ll need. Can you unscramble them properly?
. . .
That’s it! Have fun!