Set Y to () | |
set y to () | |
Category | Motion |
Type | Stack |
The Set Y to () block is a Motion block and a stack block. The block sets its sprite's Y position to the specified amount. This block, combined with the Set X to () block, have the same effect as the Go to X: () Y: () block.
Example Uses
If a sprite must go to a certain place, and the sprite's X position is to remain the same, the Set Y to () block can be used instead of the Go to X: () Y: () block — there is no need to set the X position if it does not change.
Another common use of the block is Y scrolling — the sprites have to constantly change their Y position. The Set Y to () block is normally used here.
Other common uses are:
- Placing platforms to climb up a wall
when gf clicked forever if <mouse down?> then set y to (mouse y) stamp say [Platform added!] for (2) secs end
- Setting random heights for airplanes
when gf clicked say [Ready for lift-off!] set y to (pick random (120) to (180))
- Resetting the Y position of a slider
when I receive [reset slider position v] set y to (0)
Workaround
- Main article: List of Block Workarounds
This block can be replicated with either of the following codes:
change y by ((Wanted Y) - (y position))
or
go to x: (x position) y: (Wanted Y)