public abstract class GameApplication extends FXGLApplication
The following phases are NOT executed on UI thread
Unless explicitly stated, methods are not thread-safe and must be executed on the JavaFX Application (UI) Thread. By default all callbacks are executed on the JavaFX Application (UI) Thread.
Callback / listener notes: instance of GameApplication will always be notified last along the chain of callbacks. However, as per documentation, events are always fired after listeners.
log| Constructor and Description |
|---|
GameApplication() |
| Modifier and Type | Method and Description |
|---|---|
GameScene |
getGameScene() |
GameState |
getGameState() |
GameWorld |
getGameWorld() |
MenuEventListener |
getMenuListener() |
PhysicsWorld |
getPhysicsWorld() |
protected void |
initAchievements()
Override to register your achievements.
|
protected void |
initAssets()
Initialize game assets, such as Texture, Sound, Music, etc.
|
protected void |
initGame()
Initialize game objects.
|
protected void |
initGameVars(Map<String,Object> vars)
Can be overridden to provide global variables.
|
protected void |
initInput()
Initialize input, i.e.
|
protected void |
initPhysics()
Initialize collision handlers, physics properties.
|
protected SceneFactory |
initSceneFactory()
Override to provide custom intro/loading/menu scenes.
|
protected void |
initUI()
Initialize UI objects.
|
boolean |
isMenuOpen() |
boolean |
isPaused() |
protected void |
loadState(DataFile dataFile)
Called when MenuEvent.LOAD occurs.
|
protected void |
onPostUpdate(double tpf)
Called after main loop tick has been completed.
|
protected void |
onUpdate(double tpf)
Main loop update phase, most of game logic.
|
protected void |
preInit()
This is called after core services are initialized
but before any game init.
|
protected DataFile |
saveState()
Called when MenuEvent.SAVE occurs.
|
protected void |
startLoadedGame(DataFile dataFile)
(Re-)initializes the user application from the given data file and starts the game.
|
protected void |
startNewGame()
(Re-)initializes the user application as new and starts the game.
|
addFXGLListener, exit, getAchievementManager, getAppBounds, getAssetLoader, getAudioPlayer, getDisplay, getEventBus, getExceptionHandler, getExecutor, getHeight, getInput, getMasterTimer, getNet, getNotificationService, getNow, getPrimaryStage, getQTE, getQuestService, getSettings, getTick, getUIFactory, getWidth, init, initSettings, pause, removeFXGLListener, reset, resume, start, stoppublic final GameState getGameState()
public final GameWorld getGameWorld()
public final PhysicsWorld getPhysicsWorld()
public final GameScene getGameScene()
protected SceneFactory initSceneFactory()
protected void initAchievements()
Example:
AchievementManager am = getAchievementManager();
am.registerAchievement(new Achievement("Score Master", "Score 20000 points"));
protected void initInput()
Note: This method is called prior to any game init to register input mappings in the menus.
Example:
Input input = getInput();
input.addAction(new UserAction("Move Left") {
protected void onAction() {
playerControl.moveLeft();
}
}, KeyCode.A);
protected void preInit()
protected void initAssets()
protected DataFile saveState()
UnsupportedOperationException - if was not overriddenprotected void loadState(DataFile dataFile)
dataFile - previously saved dataUnsupportedOperationException - if was not overriddenprotected void initGameVars(Map<String,Object> vars)
vars - map containing CVars (global variables)protected void initGame()
protected void initPhysics()
protected void initUI()
protected void onUpdate(double tpf)
tpf - time per frameprotected void onPostUpdate(double tpf)
tpf - time per frame (same as main update tpf)public boolean isMenuOpen()
public boolean isPaused()
protected void startNewGame()
protected void startLoadedGame(DataFile dataFile)
dataFile - save data to load frompublic MenuEventListener getMenuListener()
IllegalStateException - if menus are not enabledCopyright © 2017. All rights reserved.