Scratch for Java

Stage::getTimer()

Returns the default timer or a timer with the given name. For more information about timer see the documentation for the Timer class.

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

.getTimer()
.getTimer(name)

Scratch

(time [name v])

Parameters

Name Data Type Description
name String The name of the timer

Return

Timer

getTimer()