Game Development Reference
In-Depth Information
Creating multiple targets
We will write a script for the target we just drew; this script will place copies of the object
at random locaions on the stage. To do this we will use the new clone block. This is one of
the most exciing new features of Scratch 2.0. Instead of manually copying your sprites N
number of imes, you can just use a script to do this work for you. It can save a lot of ime
when creaing and ediing objects.
1. This script will start with a when <green lag> clicked block, just like the earlier ones.
2. Atach a go to x: () y: () block. Fill in the numbers -100 and 0 .
About X-Y coordinates
X stands for the horizontal position, that is, how far left or right something is. Y
stands for the vertical position, that is, how high or low something is. This way
the computer can easily save the position of any object on the stage. Look at the
bottom-right corner of the stage. Here you will see the current position of the
mouse shown as X and Y coordinates. This can be a helpful tool when deciding
where you want objects to appear on stage with a script. Just point to the right
place, look at the numbers, and put them at the right places in the script.
The center point of the Scratch stage has the coordinates (X:0,Y:0) . The
horizontal positions range from -240 to +240 . And the vertical positions range
from -180 to +180 . If you look at the assignment for the previous target, you will
notice that the target is placed somewhat left of the center (-100) and on the
center line vertically (0).
 
Search WWH ::




Custom Search