Scratch for Java

Timer::intervalMillis()

Checks if the specified interval in milliseconds has passed.

Examples

import org.openpatch.scratch.*;
import org.openpatch.scratch.Timer;
 
public class TimerIntervalMillis {
 
  public TimerIntervalMillis() {
    Stage myStage = new Stage(600, 240);
    Timer myTimer = new Timer();
    while (myStage.getTimer().forMillis(3000)) {
      if (myTimer.intervalMillis(500)) {
        myStage.display("Interval 1");
      } else {
        myStage.display("Interval 2");
      }
    }
    myStage.exit();
  }
 
  public static void main(String[] args) {
    new TimerIntervalMillis();
  }
}
 

View on GitHub

Syntax

Java

.intervalMillis(millis)
.intervalMillis(millis, skipFirst)
.intervalMillis(millis1, millis2)
.intervalMillis(millis1, millis2, skipFirst)

Parameters

Name Data Type Description
millis int the interval in milliseconds to check
skipFirst boolean if true, the first interval will be skipped
millis1 int the first interval in milliseconds to check
millis2 int the second interval in milliseconds to check

Return

boolean

intervalMillis()

Create Shareable URL

Select Sections