Skip to content

Customizing Menus

Almas Baimagambetov edited this page Apr 24, 2018 · 5 revisions

Custom Menus

FXGL uses the factory pattern to deal with menu objects. To provide your own menu implementation, there are two things of note:

  1. Create your menu class that extends FXGLMenu
  2. Create your factory class that extend SceneFactory

Menu class

See FXGLDefaultMenu for sample code.

public class MyMenu extends FXGLMenu {
    public MyMenu (GameApplication app, MenuType type) {
        super(app, type);

        // code to customize the view of your menu
    }
}

Factory class

See this for sample code.

public class MySceneFactory extends SceneFactory {

        @Override
        public FXGLMenu newMainMenu(GameApplication app) {
            return ...
        }

        @Override
        public FXGLMenu newGameMenu(GameApplication app) {
            return ...
        }
}
Clone this wiki locally