public final class GameLoop extends UpdateLoop implements IGameLoop
IUpdatable
instances.
Subsequently, it performs the rendering of the current frame and tracks some performance metrics on the process.IUpdateable.update()
,
Game.loop()
,
RenderComponent.render()
Modifier and Type | Field and Description |
---|---|
static int |
TICK_DELTATIME_LAG
The tick
UpdateLoop.getDeltaTime() at which we consider the game not to run fluently anymore. |
Modifier and Type | Method and Description |
---|---|
void |
alterExecutionTime(int index,
long ticks)
Alters the execution time of the timed action with the specified index to the defined tick.
|
protected long |
getExpectedDelta() |
float |
getTimeScale()
Gets the game loop's current time scale (default = 1).
|
int |
perform(int delay,
java.lang.Runnable action)
Performs a timed action with the specified delay in ms.
|
protected void |
process()
In addition to the normal base implementation, the
GameLoop performs registered action at the required
time and tracks some detailed metrics. |
void |
removeAction(int id)
Removes the
TimedAction with the specified it. |
void |
setTimeScale(float timeScale)
Sets the game loop's time scale.
|
attach, close, delay, detach, getDeltaTime, getLock, getProcessTime, getTickRate, getTicks, getUpdatableCount, getUpdatables, run, setTickRate, terminate, update
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
attach, detach, getDeltaTime, getLock, getProcessTime, getTickRate, getTicks, getUpdatableCount, setTickRate
start, terminate
public static final int TICK_DELTATIME_LAG
UpdateLoop.getDeltaTime()
at which we consider the game not to run fluently anymore.
public int perform(int delay, java.lang.Runnable action)
IGameLoop
perform
in interface IGameLoop
delay
- The delay in milliseconds.action
- The action to perform, once the delay has passed.TimedAction
that can be used to alter the execution time of the action or remove it.IGameLoop.alterExecutionTime(int, long)
public float getTimeScale()
IGameLoop
getTimeScale
in interface IGameLoop
public void setTimeScale(float timeScale)
IGameLoop
This can be used to fast-forward the gameplay or to introduce slow-motion effects.
setTimeScale
in interface IGameLoop
timeScale
- The time scale to set.public void alterExecutionTime(int index, long ticks)
IGameLoop
alterExecutionTime
in interface IGameLoop
index
- The id of the TimedAction
.ticks
- The tick at which to perform the action instead.public void removeAction(int id)
IGameLoop
TimedAction
with the specified it.removeAction
in interface IGameLoop
id
- The id of the TimedAction
.protected void process()
GameLoop
performs registered action at the required
time and tracks some detailed metrics.process
in class UpdateLoop
protected long getExpectedDelta()
getExpectedDelta
in class UpdateLoop