Class Timer
java.lang.Object
ActiverseUtils.Timer
Advanced Timer class for game loop timing, delays, and repeated events.
Part of the Activerse engine.
- Version:
- 1.4.0
- Author:
- Knivier
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongReturns how much time has elapsed in milliseconds.longReturns the remaining time in milliseconds, or 0 if expired.booleanReturns true if the timer has finished (only applies if duration > 0).booleanisPaused()Returns true if the timer is paused.booleanReturns true if the timer is set to repeat.booleanReturns true if the timer is currently running (not paused or stopped).voidpause()Pauses the timer.voidreset()Resets the timer without stopping it.voidresume()voidsetDuration(long durationMillis) Set a new duration for the timer (in milliseconds).voidsetRepeat(boolean repeat) Set whether the timer should repeat.voidstart()Starts or restarts the timer.voidstop()Stops the timer completely.
-
Constructor Details
-
Timer
public Timer(long durationMillis, boolean repeat) Constructs a Timer with optional duration and repeat flag.- Parameters:
durationMillis- Timer duration in milliseconds (0 for infinite)repeat- Whether the timer repeats after duration
-
Timer
public Timer()Constructs a Timer with no duration (manual control).
-
-
Method Details
-
start
public void start()Starts or restarts the timer. -
stop
public void stop()Stops the timer completely. -
pause
public void pause()Pauses the timer. -
resume
public void resume() -
reset
public void reset()Resets the timer without stopping it. -
getElapsedTime
public long getElapsedTime()Returns how much time has elapsed in milliseconds. -
getRemainingTime
public long getRemainingTime()Returns the remaining time in milliseconds, or 0 if expired. -
isFinished
public boolean isFinished()Returns true if the timer has finished (only applies if duration > 0). Automatically resets if repeating. -
isRunning
public boolean isRunning()Returns true if the timer is currently running (not paused or stopped). -
isPaused
public boolean isPaused()Returns true if the timer is paused. -
isRepeating
public boolean isRepeating()Returns true if the timer is set to repeat. -
setDuration
public void setDuration(long durationMillis) Set a new duration for the timer (in milliseconds). -
setRepeat
public void setRepeat(boolean repeat) Set whether the timer should repeat.
-