From Test-Scratch-Wiki
重复直到 () | |
重複直到 () | |
类别 | 控制类积木 |
形狀 | 条形积木 |
加入於 | 1.1 |
The Repeat Until () 积木 is a 控制类积木 and a 半框形积木. Blocks held inside this block will loop until the specified 菱形积木 statement is true, in which case the code beneath the block (if any) will execute. This loop is in similar nature to a while
loop in some other 编程语言.
用法示例
As this block loops pieces of code until a condition is true, the block is the best way to run code until a desired condition has been reached. Some common uses:
- Moving a sprite until its X or y 座標 is at a certain amount
重複直到 <(x座標) = [100]> 移動 (10) 點 end
- Having a sprite stick to the mouse until the mouse is not down
重複直到 <<滑鼠鍵被按下?> 不成立> 定位到 [鼠標 v] 位置 end
- Waiting for an event while performing an action
重複直到 <condition> . . . end
計時器重置 重複直到 <(計時器) > (limit)> . . . end
应用
- Main article: List of Block Workarounds
This block can be worked around with the following code:
重複無限次 . . . 如果 <condition> 那麼 廣播訊息 [next v] 停止 [這個程式 v] end end
當收到訊息 [next v] . . .
These can break scripts and should be avoided when making 一角色一脚本类专案 专案, however.