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 voidThis method can be used instead to execute a job after a specified time.floatGet current progress.voidThis method shall be invoked by the logic everyGameConf.LOGIC_DELTAms.voidoffset(long offset) Subtract an offset at beginning.voidreset()Reset the time.static voidsleep(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 waitingbooleantimeUp()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_DELTAms. -
timeUp
public boolean timeUp()Indicates whether the time is up.- Returns:
trueif time is up;falseotherwise
-
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
-