Interface ILoop
- All Superinterfaces:
ILaunchable
- All Known Subinterfaces:
IGameLoop
- All Known Implementing Classes:
GameLoop,UpdateLoop
The
ILoop interface provide method for game loops that are publicly exposed.
A loop is an implementation that performs actions (e.g. physics, rendering, input processing, ...) and updates other
IUpdatable instances while the game is running.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidattach(IUpdateable updatable) Attaches the update method of the specified IUpdatable instance to be called every tick.voiddetach(IUpdateable updatable) Detaches the specified instance from the game loop.longGets the total time in milliseconds that passed since the last tick.getLock()Returns a lock that can be used for actions that must be performed either within or independently of the loop.doubleGets the actual process time in milliseconds that was required during the last tick.intGets the rate at which this loop performs its updates.longgetTicks()Gets the total amount of ticks performed by this loop since it was started.intGets the amount of attachedIUpdatableinstances of this loop.voidsetTickRate(int tickRate) Sets the tickrate at which the loop performs its updates.Methods inherited from interface de.gurkenlabs.litiengine.ILaunchable
start, terminate
-
Method Details
-
attach
Attaches the update method of the specified IUpdatable instance to be called every tick. The tick rate can be configured in the client configuration and is independent from rendering.- Parameters:
updatable- The instance that will be registered for the update event.
-
detach
Detaches the specified instance from the game loop.- Parameters:
updatable- The instance that will be unregistered for the update event.
-
getUpdatableCount
int getUpdatableCount()Gets the amount of attachedIUpdatableinstances of this loop.- Returns:
- The amount instances attached to this loop.
-
getTicks
long getTicks()Gets the total amount of ticks performed by this loop since it was started.- Returns:
- The total amount of elapsed ticks.
- See Also:
-
getTickRate
int getTickRate()Gets the rate at which this loop performs its updates.- Returns:
- The update rate in ticks per second.
-
getDeltaTime
long getDeltaTime()Gets the total time in milliseconds that passed since the last tick.
i.e. process time + delay (to enforce the tick rate of this loop)- Returns:
- The delta time in ms.
- See Also:
-
getProcessTime
double getProcessTime()Gets the actual process time in milliseconds that was required during the last tick.
i.e. delta time - delay- Returns:
- The actual process time of the last tick in ms.
- See Also:
-
getLock
Lock getLock()Returns a lock that can be used for actions that must be performed either within or independently of the loop.- Returns:
- A
Lockfor this loop.
-
setTickRate
void setTickRate(int tickRate) Sets the tickrate at which the loop performs its updates.- Parameters:
tickRate- The tickrate of the loop.
-