Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Knowledge Base
  3. 2D Blocks
  4. X and Y Positions

X and Y Positions

Scheduled Pinned Locked Moved 2D Blocks
1 Posts 1 Posters 3.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

    Introduction

    When we add a sprite, we often need to tell the computer where to place it. If we just say “place Cody on the top right corner”, that could mean many different locations:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/f53e3d24-6b12-4291-a549-b81337d4d6ab.png" width="500" style="border-radius: 5px; border: 1px solid #29622d;">

     
    To be more exact, we can use “X position” to tell the computer how far left or right is the sprite. X position is a number between -240 and 240:

    • If x position is 240, the sprite’s center will be at the right edge of the stage;
    • If x position is -240, the sprite’s center will be at the left edge of the stage;
    • If x position is 0, the sprite’s center will be in the middle of the stage;

    You can try different values for the x position using the input box below the stage. Note that the red dot is the center of the sprite.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/2fb247fe-fcfb-4375-9052-d4a3c92fb270.gif" width="500" style="border-radius: 5px; border: 1px solid #29622d;">

     
    Similarly, we can use “Y position” to specify how high or low is the sprite’s position, which can be any number between -180 and 180:

    • If y position is 180, the sprite’s center will be at the top edge of the stage;
    • If y position is -180, the sprite’s center will be at the bottom edge of the stage;
    • If y position is 0, the sprite’s center will be in the vertical middle of the stage;

    You can also try different values for the y position using the input box below the stage.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/788f7d41-b25a-4405-a396-c8506f16ebdb.gif" width="500" style="border-radius: 5px; border: 1px solid #29622d;">

     

    The “Xy-grid” Backdrop

    To help you find the correct position values, you can use a backdrop called “Xy-grid”:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/746ec66c-872f-460c-b76f-531e6908cb28.png" width="800" style="border-radius: 5px; border: 1px solid #29622d;">

    This grid contains 2 lines that intersect at the center of the stage, where x is 0 and y is 0. The orange line is the “X-axis”, and the blue line is the “Y-axis”.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/4e45a259-267c-454b-b1c2-29c7ae3966e4.png" width="500" style="">

     

    The “Set X To” Block

    To move a sprite to an X position, you can use the “set x to” block in the Motion category. The x position below the stage also changes to reflect the change.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/b9b3ba9f-c0aa-449a-a60f-857f1876f2d5.gif" width="700" style="border-radius: 5px; border: 1px solid #29622d;">

     

    The “Set Y To” Block

    Similarly, you can move a sprite to any Y position using the “set y to” block. Note that when you change the Y position of a sprite, its X position will not be affected.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c7d231cf-0750-4705-ae58-62adbbca5e39.gif" width="700" style="border-radius: 5px; border: 1px solid #29622d;">

     

    The “Go To X Y” Block

    You can also set both the X and Y positions at the same time, using the “go to x y” block. It has the same result as running “set x to” then “set y to” blocks.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/da280e30-ceb1-49d0-b30a-277db311d2ef.gif" width="760" style="border-radius: 5px; border: 1px solid #29622d;">

     

    The “Glide To X Y” Block

    You can also create an animation when you move a sprite, using the “glide to x y” block. You can specify an additional input for how long it takes the sprite to move there.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/e5f729df-f848-4d51-a46f-d9ed8ffdc944.gif" width="760" style="border-radius: 5px; border: 1px solid #29622d;">

     

    Reading “X Position” and “Y Position”

    If you need to find out the current X and Y positions of the sprite, you can use these 2 reporter blocks:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/d4052b17-78bf-4097-b6e3-079c341288a2.gif" width="700" style="border-radius: 5px; border: 1px solid #29622d;">

    1 Reply Last reply
    0
    • CreatiCodeI CreatiCode pinned this topic on

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode