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座標) = > 移動 (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] . . .