-
-
Notifications
You must be signed in to change notification settings - Fork 556
Customizing Menus
Almas Baimagambetov edited this page Oct 21, 2020
·
5 revisions
FXGL uses the factory pattern to deal with menu objects. To provide your own menu implementation, there are two things of note:
- Create your menu class that extends
FXGLMenu
- Create your factory class that extend
SceneFactory
See FXGLDefaultMenu for sample code.
public class MyMenu extends FXGLMenu {
public MyMenu(MenuType type) {
super(type);
// code to customize the view of your menu
}
}
public class MySceneFactory extends SceneFactory {
@Override
public FXGLMenu newMainMenu() {
return new MyMenu(MenuType.MAIN_MENU);
}
@Override
public FXGLMenu newGameMenu() {
return new MyMenu(MenuType.GAME_MENU);
}
}
...
settings.setSceneFactory(new MySceneFactory());