Game Development Reference
In-Depth Information
We have to create a variable to store the direcion of the cannon. If you're unfamiliar
with variables, read the informaion box on the following page. To create a variable,
follow these steps:
1. Click on the Data category. This is where you can create variables.
2. We will now click on the Make a Variable buton.
3. Name the variable direction and make it available for all sprites .
4. We start the program with the when <green lag> clicked block. This is the easiest
way to set any program in moion.
5. Underneath it, we will place a forever block, because we will check the cannon's
direcion indeinitely.
6. If you want, you can ick the checkbox to make the variable visible on stage.
Then, you can see the direcion that the cannon is facing in, at all imes.
Put a set () to () block in the forever block and select direcion .
View the Moion category and look down at the list of blocks to find the built-in
cannon direcion variable. Place it in the open space. It may look superfluous to
send the built-in variable value to a self-made variable. We do this because Scratch
can't send built-in sprite variables to other sprites directly. Our self-made variable
can be used in all sprites.
This is all the scriping that has to be done for the cannon. The following is the
finished script:
Search WWH ::

Custom Search