如何在 Scratch 中模拟 While 循环?

How to Simulate While Loops in Scratch?

在大多数编程语言中,有一个 "while" 循环在条件为真时运行代码。然而,在 Scratch 中,只有一个 "repeat until" 循环重复直到条件为真。如何在 Scratch 中模拟 "while" 循环?

假设您想使用 "while" 循环到 运行,而 "ConditionA" 为真。

WHILE 条件 A
说 "hello"

在Scratch中,你可以这样使用"repeat until"循环:

重复直到条件 A
说 "hello"

这很简单。只需循环一个“if”运算符。

forever
  if <...>
    code goes here
  else
  end
end