Package rekit.primitives.time
Class Timer
java.lang.Object
rekit.primitives.time.Timer
Data class that holds an duration time.
- Author:
- Angelo Aracri
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
This method can be used instead to execute a job after a specified time.float
Get current progress.void
This method shall be invoked by the logic everyGameConf.LOGIC_DELTA
ms.void
offset
(long offset) Subtract an offset at beginning.void
reset()
Reset the time.static void
sleep
(long offset) This method can be used instead ofThreadUtils.sleep(long)
ifGameTime.pause()
shall take effect.
Be careful: If game is paused, this method will cause endless waitingboolean
timeUp()
Indicates whether the time is up.
-
Constructor Details
-
Timer
public Timer(long duration) Create a TimeDependency by duration time.- Parameters:
duration
- the duration time in millis
-
-
Method Details
-
logicLoop
public void logicLoop()This method shall be invoked by the logic everyGameConf.LOGIC_DELTA
ms. -
timeUp
public boolean timeUp()Indicates whether the time is up.- Returns:
true
if time is up;false
otherwise
-
reset
public void reset()Reset the time. -
getProgress
public float getProgress()Get current progress.- Returns:
- percentage as float in [0,1]
-
offset
public void offset(long offset) Subtract an offset at beginning.- Parameters:
offset
- the offset
-
sleep
public static void sleep(long offset) This method can be used instead ofThreadUtils.sleep(long)
ifGameTime.pause()
shall take effect.
Be careful: If game is paused, this method will cause endless waiting- Parameters:
offset
- the time to wait in millis
-
execute
This method can be used instead to execute a job after a specified time.- Parameters:
offset
- the time to wait in millisr
- the job
-