Scratch for Java

Stage::waitUntil()

Waits until something becomes true, then carries on.

Like wait(int) this holds up the code that calls it, not the whole program: sprites keep running and the stage keeps drawing while it waits. That makes it useful for setting a scene up in a constructor, and a bad idea inside run(), which is called once per frame and should return quickly.

this.ask("What is your name?");
 this.waitUntil(() -> !this.isAsking());
 this.display("Hello " + this.getAnswer() + "!");

Syntax

Java

.waitUntil(condition)

Scratch

wait until <condition>

Parameters

Name Data Type Description
condition BooleanSupplier checked over and over until it is true

Return

void

waitUntil()

Create Shareable URL

Select Sections