Scratch for Java

Timer::everyMillis()

Checks if the specified number of milliseconds has passed since the last time this method returned true.

Examples

import org.openpatch.scratch.*;
import org.openpatch.scratch.Timer;
 
public class TimerEveryMillis {
 
  public TimerEveryMillis() {
    Stage myStage = new Stage(600, 240);
    Timer myTimer = new Timer();
    int i = 0;
    while (myStage.getTimer().forMillis(3000)) {
      if (myTimer.everyMillis(500)) {
        myStage.display("Count: " + i++);
      }
    }
    myStage.exit();
  }
 
  public static void main(String[] args) {
    new TimerEveryMillis();
  }
}
 

View on GitHub

Syntax

Java

.everyMillis(millis)

Parameters

Name Data Type Description
millis int The number of milliseconds to wait before returning true.

Return

boolean

everyMillis()

Create Shareable URL

Select Sections