(Redirected from Set X to ())
Set X to () | |
set x to () | |
Category | Motion |
Type | Stack |
Introduced in | 11Jun04 (0.x) |
The Set X to () block is a Motion block and a stack block. The block changes the selected sprite's X position to the specified value. Along with the Set Y to () block, this block acts similarly to the Go to X: () Y: () block.
Example Uses
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)
Workaround
- 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)