Scratch for Java

Timer::forMillis()

Returns true for a given amount of milliseconds

Examples

import org.openpatch.scratch.*;
import org.openpatch.scratch.extensions.timer.Timer;

public class TimerForMillis {

  public TimerForMillis() {
    Stage myStage = new Stage(600, 240);
    Timer myTimer = new Timer();
    myStage.display("Start!");
    myStage.wait(500);
    while (myTimer.forMillis(1000)) {
      myStage.display("Running...");
    }
    ;
    myStage.display("Stop!");
    myStage.wait(500);
    myStage.exit();
  }

  public static void main(String[] args) {
    new TimerForMillis();
  }
}

View on GitHub

Syntax

Java

.forMillis(millis)

Scratch

Parameters

NameData TypeDescription
millisbooleanTime in milliseconds to return true. Afterwards return false.

Return

boolean