Y position: Difference between revisions
Y position
Content deleted Content added
No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
|block_name = y position |
|block_name = y position |
||
}} |
}} |
||
The '''y position''' block is a reporter block that reports the current y position of the sprite. It originates from [[Scratch]]. |
The '''y position''' block is a reporter block that reports the current y position of the sprite. It originates from [[Scratch]]. The default y position for paint sprites or blank sprites is 28, while other new sprites start at a random position. In the default project, the Penguin sprite is at (0, 0). |
||
==Workaround== |
==Workaround== |
||
This block can be worked around by using a [[Variables (subcategory)|variable]] to save the y position when the [[set y to ()]] or [[change y by ()]] blocks are used: |
This block can be worked around by using a [[Variables (subcategory)|variable]] to save the y position when the [[set y to ()]] or [[change y by ()]] blocks are used: |
||
Line 16: | Line 16: | ||
</scratchblocks> |
</scratchblocks> |
||
However, this workaround does not account for the y position limit if offscreen, or "Remove Fencing" is disabled. |
However, this workaround does not account for the y position limit if offscreen, or "Remove Fencing" is disabled. |
||
==See also== |
|||
*[[x position]] |
|||
*[[y stretch]] |
|||
*[[y velocity]] |
|||
*[[y scroll]] |
|||
*[[() position of object named ()]] |
|||
{{DISPLAYTITLE:y position}} |
{{DISPLAYTITLE:y position}} |
||
{{Blockcat|type=Reporter|cat=Motion|sc=y}} |
{{Blockcat|type=Reporter|cat=Motion|sc=y}} |
Latest revision as of 23:30, 8 July 2024
y position | |
---|---|
y position | |
Block Type | Reporter Block |
Category / Extension | Motion |
The y position block is a reporter block that reports the current y position of the sprite. It originates from Scratch. The default y position for paint sprites or blank sprites is 28, while other new sprites start at a random position. In the default project, the Penguin sprite is at (0, 0).
Workaround
This block can be worked around by using a variable to save the y position when the set y to () or change y by () blocks are used:
define set y to (number1) set [y pos v] to (number1) set y to (number1) define change y by (number1) set y to ((number1) + (y pos))::custom
However, this workaround does not account for the y position limit if offscreen, or "Remove Fencing" is disabled.