From Test-Scratch-Wiki

Revision as of 06:55, 2 April 2018 by Dnowba (talk | contribs) (Created page with "{{:Eng:Set Y to () (block)/translate}} {{Zho/积木 | 名 = Y 设为 () | sb = Y 設為 () | 类别 = 动作类积木 | 形狀 = Z...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Translate: - English - 中文 
Y 设为 ()
Y 設為 ()
类别 动作类积木
形狀 条形积木

The Set Y to () 积木 is a 动作类积木 and a 条形积木. The block sets its 角色的 Y (up and down) position to the specified amount. This block, combined with the X 设为 () block, have the same effect as the 定位到 X:() Y:() block.

用法示例

If a sprite must go to a certain place, and the sprite's x座標 is to remain the same, the Set Y to () block can be used instead of the 定位到 X:() Y:() block — there is no need to set the x座標 if it does not change.

Another common use of the block is Y 卷轴滚动 — the sprites have to constantly change their y 座標. The Set Y to () block is normally used here.

Other common uses are:

  • Placing platforms to climb up a wall
當 @greenflag 被點擊
重複無限次 
  如果 (mouse down?) 那麼 
    y 設為 (滑鼠游標的 y)
    蓋章
    說出 [Platform added!] (2) 秒
  end
end
  • Setting random heights for airplanes
當 @greenflag 被點擊
說出 [Ready for lift-off!]
y 設為 (隨機取數 (120) 到 (180))
  • Resetting the y 座標 of a slider
當收到訊息 [reset slider position v]
y 設為 (0)

应用

Main article: List of Block Workarounds

This block can be replicated with either of the following codes:

y 改變 ((Wanted Y) - (y 座標))

or

定位到 x: (x 座標) y: (Wanted Y)

参见