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 TypeMethodDescriptionlong
Returns how much time has elapsed in milliseconds.long
Returns the remaining time in milliseconds, or 0 if expired.boolean
Returns true if the timer has finished (only applies if duration > 0).boolean
isPaused()
Returns true if the timer is paused.boolean
Returns true if the timer is set to repeat.boolean
Returns true if the timer is currently running (not paused or stopped).void
pause()
Pauses the timer.void
reset()
Resets the timer without stopping it.void
resume()
void
setDuration
(long durationMillis) Set a new duration for the timer (in milliseconds).void
setRepeat
(boolean repeat) Set whether the timer should repeat.void
start()
Starts or restarts the timer.void
stop()
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.
-