public class GameEngine
extends java.lang.Object
The provider for the game's main loop logic
GameEngine should usually not be extended; instead, users of this
class should create a new GameEngine() and add subclasses of
GameSystem to handle the implementation.
| Constructor and Description |
|---|
GameEngine() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Entity entity)
Add an entity to the engine
|
void |
add(GameSystem system)
Add a
GameSystem to the engine, calling its
GameSystem.onStart(GameEngine) method and setting it to the
lowest priority. |
void |
add(GameSystem system,
int priority)
Add a
GameSystem to the engine, calling its
GameSystem.onStart(GameEngine) method and setting it to the given
priority. |
void |
pause()
Temporarily stop all processing on this engine, until a
subsequent call to
resume() is made. |
void |
remove(java.lang.Class<? extends GameSystem> systemType)
Remove a
GameSystem from the engine |
void |
remove(Entity entity)
Remove an entity from the engine
|
void |
remove(GameSystem system)
Remove a
GameSystem from the engine |
void |
resume()
Resume handling update calls, and call
GameSystem.onResume()
on all attached systems which were running before the engine was paused. |
void |
update(float deltaTime)
Tell all
GameSystems in this engine to execute. |
public void add(GameSystem system)
Add a GameSystem to the engine, calling its
GameSystem.onStart(GameEngine) method and setting it to the
lowest priority.
system - The system to addpublic void add(GameSystem system, int priority)
Add a GameSystem to the engine, calling its
GameSystem.onStart(GameEngine) method and setting it to the given
priority.
system - The system to addpriority - The priority to set. In future releases, systems at the
same priority will be eligible for concurrent execution.public void update(float deltaTime)
Tell all GameSystems in this engine to execute.
Call this from your main game loop to perform all entity updates and rendering.
deltaTime - The time, in seconds, since the last updatepublic void remove(GameSystem system)
Remove a GameSystem from the engine
system - The system to removepublic void remove(java.lang.Class<? extends GameSystem> systemType)
Remove a GameSystem from the engine
systemType - The type of the system to removepublic void add(Entity entity)
Add an entity to the engine
entity - Entity to addpublic void remove(Entity entity)
Remove an entity from the engine
entity - Entity to removepublic void pause()
Temporarily stop all processing on this engine, until a
subsequent call to resume() is made. Calling
update(float) while paused does nothing.
Also calls GameSystem.onPause() on all attached systems which
are not already paused
public void resume()
Resume handling update calls, and call GameSystem.onResume()
on all attached systems which were running before the engine was paused.