Package model.utilz
Class PlayingTimer
java.lang.Object
model.utilz.PlayingTimer
Singleton class that manages the playing timer, used to heep track of the time delta between updates.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PlayingTimerReturns the singleton instance of the PlayingTimer.longReturns the time delta between the last two updates.voidResets the timer for a new play session.voidreset()Resets the timer by setting the last timer update time to the current system time.voidupdate()Updates the timer.
-
Method Details
-
getInstance
Returns the singleton instance of the PlayingTimer.- Returns:
- the singleton instance
-
update
public void update()Updates the timer. Calculates the time delta since the last update. If this is the first update, initializes the last timer update time. -
reset
public void reset()Resets the timer by setting the last timer update time to the current system time. -
newPlayReset
public void newPlayReset()Resets the timer for a new play session. Sets the first update flag to true and resets the time delta. -
getTimeDelta
public long getTimeDelta()Returns the time delta between the last two updates.- Returns:
- the time delta in milliseconds
-