In this exercise, we're going to start the scene by positioning the dog in front of the microphone and end the scene by lying the dog on its side.
We issued a series of commands, and our dog responded with precision. The first command sets the dog's X and Y position next to the microphone. The second command moves the dog to the new X and Y coordinates in front of the dresser. The 2 seconds we specified in the glide block means the dog takes 2 seconds to reach the new coordinates. If we wanted the sprite to amble along, we could set a higher value, such as 10 seconds.
When we built the horse scene, we didn't need to know the position of the horse because it didn't move. Each time we displayed the horse, it was in the same location.
However, the dog changes position as the scene plays out, and since Scratch remembers the sprite's previous position, we need to ensure that the dog always starts in front of the microphone when the scene starts.
The X axis divides the stage into equal halves horizontally, and the Y axis divides the stage into equal halves vertically. The two axes intersect in the middle of the screen or at coordinates (0,0).
If a sprite has a positive X value, it's positioned in the right half of the stage. If a sprite has a positive Y value, it's positioned in the top half of the stage. A negative X value can be found in the left half of the stage, and a negative Y value can be found in the bottom half of the stage.
The following table defines several key locations on the stage. The coordinates are listed in the format (X,Y):
Coordinate |
Description |
More Information |
---|---|---|
(0,0) |
Marks the center of the stage. |
To set a sprite in the middle of the stage horizontally, specify X:0. To set a sprite in the middle vertically, specify Y:0. |
(240,0) |
Marks right edge of the stage. |
Specify a Y value to move up or down the right edge. |
(-240,0) |
Marks the left edge of the stage. |
Specify a Y value to move up or down the left edge. |
(0,180) |
Marks the top edge of the stage. |
Specify an X value to move right or left across the top edge. |
(0,-180) |
Marks the bottom edge of the stage. |
Specify an X value to move right or left across the bottom edge. |
The following screenshot shows the Scratch stage with an (X,Y) grid as a background. This grid is one of Scratch's included backgrounds.