Zho:与 () 的间距（积木）

The Distance to  积木 is a 侦测类积木 and a 椭圆形积木. The block reports the 距离 (a measurement of pixels) between it and a specified 角色的 造型中心点, or the 滑鼠游标.

用法示例
As this block can give distances between objects, it is very useful in 专案 that require a great deal of careful sensing and movement.

Some common uses for the Distance to block: 如果 <(與 [snowball v] 的間距) < (40)> 那麼 說出 [Watch out!] 等待直到 <碰到 [snowball v] ?> 說出 [] // stop saying the message end 變數 [movements v] 設為 ([ceiling v] 數值 ((與 [meteor v] 的間距) / (10))) // "movements" being the amount of 10 pixel motions to reach the meteor 變數 [real distance v] 設為 (字串組合 ((與 [asteroid v] 的間距) * (10000)) 和 [ kilometers]) // for relating pixel distance to real life
 * Estimating when collisions will occur
 * Helping determine how long it should take a sprite to move somewhere, judging from the distance
 * Determining how far a rocket should fire

应用
This block can be replicated with the following code: ([sqrt v] 數值 ((((x座標) - ([x座標 v] \( [Wanted Sprite v] \))) * ((x座標) - ([x座標 v] \( [Wanted Sprite v] \)))) + (((y 座標) - ([y 座標 v] \( [Wanted Sprite v] \))) * ((y 座標) - ([y 座標 v] \( [Wanted Sprite v] \))))))

Related Suggestion
Some Scratchers want a block that gives the distance to any location, not just a 角色. It would be like this:

(distance to x: y: )//category=sensing

It is technically unnecessary because it can be replicated with a similar workaround:

([sqrt v] 數值 ((((x座標) - (wanted x)) * ((x座標) - (wanted x))) + (((y 座標) - (wanted y)) * ((y 座標) - (wanted y)))))

参见

 * 距离（值）