public abstract class GameApplication
extends javafx.application.Application
Executed on JavaFX UI thread:
NOT executed on JavaFX UI thread:
Start of main game loop execution on JavaFX 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.
| Constructor and Description |
|---|
GameApplication() |
| Modifier and Type | Method and Description |
|---|---|
void |
addExitListener(ExitListener listener) |
void |
addPlayStateListener(StateListener listener) |
void |
addUpdateListener(UpdateListener listener) |
protected void |
exit()
Exit the application.
|
javafx.geometry.Rectangle2D |
getAppBounds() |
AssetLoader |
getAssetLoader() |
AudioPlayer |
getAudioPlayer() |
Display |
getDisplay() |
EventBus |
getEventBus() |
ExceptionHandler |
getExceptionHandler() |
Executor |
getExecutor() |
Gameplay |
getGameplay() |
GameScene |
getGameScene() |
GameState |
getGameState() |
GameWorld |
getGameWorld() |
int |
getHeight() |
Input |
getInput() |
Timer |
getMasterTimer() |
MenuEventListener |
getMenuListener() |
Net |
getNet() |
NotificationService |
getNotificationService() |
PhysicsWorld |
getPhysicsWorld() |
ReadOnlyGameSettings |
getSettings() |
AppStateMachine |
getStateMachine() |
long |
getTick() |
UIFactory |
getUIFactory() |
int |
getWidth() |
void |
init() |
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 abstract void |
initSettings(GameSettings settings)
Initialize app settings.
|
protected void |
initUI()
Initialize UI objects.
|
protected void |
loadState(DataFile dataFile)
Called when MenuEvent.LOAD occurs.
|
protected void |
onPausedUpdate(double tpf)
Called every frame in any non-Play state.
|
protected void |
onPostUpdate(double tpf)
Called after main loop tick has been completed in Play state.
|
protected void |
onUpdate(double tpf)
Called every frame _only_ in Play state.
|
protected void |
preInit()
This is called after core services are initialized
but before any game init.
|
void |
removeExitListener(ExitListener listener) |
void |
removePlayStateListener(StateListener listener) |
void |
removeUpdateListener(UpdateListener listener) |
protected DataFile |
saveState()
Called when MenuEvent.SAVE occurs.
|
void |
start(javafx.stage.Stage stage)
This is the main entry point as run by the JavaFX platform.
|
protected void |
startNewGame()
(Re-)initializes the user application as new and starts the game.
|
void |
stop() |
double |
tpf() |
public final void start(javafx.stage.Stage stage)
start in class javafx.application.Applicationprotected void startNewGame()
protected final void exit()
public final MenuEventListener getMenuListener()
IllegalStateException - if menus are not enabledpublic final void addUpdateListener(UpdateListener listener)
public final void removeUpdateListener(UpdateListener listener)
public final void addExitListener(ExitListener listener)
public final void removeExitListener(ExitListener listener)
public final void addPlayStateListener(StateListener listener)
public final void removePlayStateListener(StateListener listener)
public final void init()
init in class javafx.application.Applicationpublic final void stop()
stop in class javafx.application.Applicationprotected abstract void initSettings(GameSettings settings)
settings - app settingsprotected void initAchievements()
Example:
AchievementManager am = getAchievementManager();
am.registerAchievement(new Achievement("Score Master", "Score 20000 points"));
protected void initInput()
Example:
Input input = getInput();
input.addAction(new UserAction("Move Left") {
protected void onAction() {
playerControl.moveLeft();
}
}, KeyCode.A);
protected void preInit()
protected void initAssets()
protected 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)protected void onPausedUpdate(double tpf)
tpf - time per frameprotected DataFile saveState()
UnsupportedOperationException - if was not overriddenprotected void loadState(DataFile dataFile)
dataFile - previously saved dataUnsupportedOperationException - if was not overriddenpublic final double tpf()
public final AppStateMachine getStateMachine()
public final GameState getGameState()
public final GameWorld getGameWorld()
public final PhysicsWorld getPhysicsWorld()
public final GameScene getGameScene()
public final Gameplay getGameplay()
public final Input getInput()
public final Timer getMasterTimer()
public final ReadOnlyGameSettings getSettings()
public final int getWidth()
public final int getHeight()
public final javafx.geometry.Rectangle2D getAppBounds()
public final long getTick()
public final EventBus getEventBus()
public final Display getDisplay()
public final AudioPlayer getAudioPlayer()
public final AssetLoader getAssetLoader()
public final Executor getExecutor()
public final NotificationService getNotificationService()
public final Net getNet()
public final ExceptionHandler getExceptionHandler()
public final UIFactory getUIFactory()
Copyright © 2017. All rights reserved.