Scratch for Java

Stage::addTimer()

Adds a new timer.

Examples

import org.openpatch.scratch.*;
 
public class StageTimer {
  public StageTimer() {
    Stage myStage = new Stage(600, 240);
    myStage.addTimer("identityChange");
 
    while (myStage.getTimer().forMillis(6000)) {
      if (myStage.getTimer("identityChange").everyMillis(1000)) {
        myStage.changeColor(40);
      }
    }
    myStage.exit();
  }
 
  public static void main(String[] args) {
    new StageTimer();
  }
}
 

View on GitHub

Syntax

Java

.addTimer(name)

Scratch

add timer (name)

Parameters

Name Data Type Description
name String The name of the timer

Return

void

addTimer()