Scratch for Java

Stage::addTimer()

Adds a new timer.

Examples

import org.openpatch.scratch.*;

public class StageTimer {
  public StageTimer() {
    Stage myStage = new Stage(254, 100);
    myStage.addTimer("identityChange");

    while (myStage.getTimer().forMillis(6000)) {
      if (myStage.getTimer("identityChange").everyMillis(1000)) {
        myStage.changeColor(40);
      }
    }
    Window.getInstance().exit();
  }

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

View on GitHub

Syntax

Java

.addTimer(name)

Scratch

Parameters

NameData TypeDescription
nameStringThe name of the timer

Return

void