|Set X to ()|
The Set X to () block is a Motion block and a Stack block. The block changes the selected sprite's X position to a specified value. Along with the Set Y to () block, this block acts similarly to the Go to X: () Y: () block.
If a sprite's Y coordinate must be held constant, but the sprite still needs to move (for example, a horizontal scrollbar), the Set X to () block may be used instead of the Go to X: () Y: () block — there is no need to set the Y position when it does not change.
This block is often used in projects that employ X scrolling — specified sprites constantly change their X positions to follow the motion of the landscape.
Other uses include:
- Setting the location of sprites to a random position on the screen
when gf clicked set x to (pick random (-240) to (240))
- Setting random locations for sprites so as to fill the screen (for example, a snowflake project)
- Resetting the X-coordinate of a slider
when I receive [reset slider value v] set x to (0)
- Moving a paddle in a Pong game
when gf clicked forever set x to (mouse x)
- Main article: List of Block Workarounds
This block can be replaced by one of the following:
change x by ((wanted x) - (x position))
go to x: (wanted x) y: (y position)