You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static EventHandler<ActionEvent> newGameHandler() {
if (newGameHandler == null) {
newGameHandler = _ -> FXGL.getGameController().startNewGame();
}
return newGameHandler;
}
// TODO: Returning to the main menu from this method will result in a warning and will not be successful.
public static EventHandler goBackHandler() {
if (goBackHandler == null) {
goBackHandler = new EventHandler() { @OverRide
public void handle(ActionEvent event) {
FXGL.getGameController().gotoMainMenu();
}
};
}
return goBackHandler;
}
`
Thanks, this behaviour is by design, however, it was the old design and it was never reconsidered. Leave this with me, I'll have a think about the use cases and see if I can update the design and the implementation.
In the meantime, you may wish to add a switch to game scene before you move between menus.
My partial code is as follows:
`
@OverRide
protected void initSettings(GameSettings settings) {
settings.setMainMenuEnabled(true);
settings.setGameMenuEnabled(true);
settings.setSceneFactory(new SceneFactory() {
@NotNull
@OverRide
public FXGLMenu newGameMenu() {
return new CustomGameMenu();
}
@NotNull
@OverRide
public FXGLMenu newMainMenu() {
return new CustomMainMenu();
}
`
CustomMainMenu:
`
public CustomMainMenu() {
super(MenuType.MAIN_MENU);
}
`
CustomGameMenu:
`
public CustomGameMenu() {
super(MenuType.GAME_MENU);
}
GameMenuController:
private static EventHandler newGameHandler;
private static EventHandler goBackHandler;
// TODO: Returning to the main menu from this method will result in a warning and will not be successful.
public static EventHandler goBackHandler() {
if (goBackHandler == null) {
goBackHandler = new EventHandler() {
@OverRide
public void handle(ActionEvent event) {
FXGL.getGameController().gotoMainMenu();
}
};
}
return goBackHandler;
}
`
MainMenuController:
`
private static EventHandler gameListHandler;
private static EventHandler exitHandler;
`
The text was updated successfully, but these errors were encountered: