From Test-Scratch-Wiki

Revision as of 07:29, 2 April 2018 by Dnowba (talk | contribs) (Created page with "{{:Eng:X Position (block)/translate}} {{Zho/积木 | 名 = X 座标 | sb = (X 座標) | 类别 = 动作类积木 | 形狀 = Zho:...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

X 座标
(X 座標)
类别 动作类积木
形狀 椭圆形积木

The x座標 积木 is a 动作类积木 and a 椭圆形积木. The block holds its 角色的 x座標. This block can be displayed as a 舞台监控视窗.


As this block holds its sprite's x座標, it can be used when a script needs to know its sprite's x座標. There are many cases of this — for example, you could use the block to detect how far left or right you are on the screen.

  等待直到 <(x座標) > [220]>
  變數 [Hits v] 改變 (1)

Another use is setting values based on a movable slider without using Scratch's default slider — the script sets the value to the slider's x座標.

變數 [worms v] 設為 (x 座標)

Other common uses are:

  • Comparing the x座標 with a record to check for movement
當 @greenflag 被點擊
變數 [x_pos prev v] 設為 (x 座標)
  如果 <<(x_pos prev) = (x座標)> 不成立> 那麼 
    說出 [My xpostion moved!] (2) 秒 // if the x座標 moved, say something
    變數 [x_pos prev v] 設為 (x 座標)
  • Constantly storing a sprite's X movement so it can be re-enacted later
當 @greenflag 被點擊 // script only works in a sprite!
刪除第 (全部 v) 項 \( [x座標s v] \)
刪除第 (全部 v) 項 \( [y 座標s v] \)
說出 [Move your mouse and I will reenact the movement!] (2) 秒
說出 [Go!] (1) 秒
重複 (50) 次 
  新增項目 (滑鼠游標的 x) \( [x座標s v] \)
  新增項目 (滑鼠游標的 y) \( [y 座標s v] \)
  等待 (0.1) 秒
end // records 50 coordinates at a rate of one for every 0.1 seconds
變數 [counter v] 設為 [1]
說出 [I will reenact it for you now!] (2) 秒
重複 (50) 次 
  定位到 x: (清單第 (counter) 項項目\( [x座標s v] \) :: list) y: (清單第 (counter) 項項目\( [y 座標s v] \) :: list)
  等待 (0.1) 秒
  變數 [counter v] 改變 (1)


Main article: List of Block Workarounds

The block can be simply replicated with the following block:

([x座標 v] \( [wanted sprite v] \))


Cookies help us deliver our services. By using our services, you agree to our use of cookies.