Explore the Location of Your Sprite

Explore the Location of Your Sprite on the Stage With X and Y Coordinates

1.  Before we code anything, click on your Sprite on the Stage and move it to the right. Notice how the value of the x-coordinate in the Sprites Pane gets bigger! See how the value of the x-coordinate changes from -105 to 135.


2.  Now move your Sprite to the left and notice how the value of the x-coordinate in the Sprites Pane gets smaller. Notice how the value of x changes from 135 to -35.


3.  If you move the Sprite upwards on the Stage, the value of the y-coordinate in the Sprites Pane will get bigger. Notice how the value of the y-coordinate changes from -77 to 123.


4. If you move the Sprite downwards the value of the y-coordinate in the Sprites Pane will get smaller. Notice how the value of y changes from 123 to -43.


Set the Start Position of Your Sprite

5.  Drag a “when green flag clicked” block from the Events category in the Block Palette into the Code Area.


6.  Click on your Sprite in the Stage area and drag it to the location you want your Sprite to start at everytime you run your code. This will change the x-coordinate and y-coordinate of your sprite in the Sprites Pane.


7.  Click and drag a “go to x: y” coordinates block from the Motion category in the Blocks Palette on to the Code Area. The default x-coordinate and y-coordinate input bubbles on this Motion block will be set to the exact location that your Sprite is on the Stage (which means that it will have the same coordinates that are set in the Sprites Pane). This block will tell your sprite to go to that location every time you press the Green Flag.



Views
1 Total Views
1 Members Views
0 Public Views
Share on Social Networks
Share Link
Share by mail

Please login to share this webpage by email.