Skip to content

Customizing Menus

Almas Baimagambetov edited this page Jul 24, 2017 · 5 revisions

Providing own menu implementations

    protected void initSettings(GameSettings settings) {
        settings.setWidth(800);
        settings.setHeight(600);
        settings.setTitle("MenuStyleSample");
        settings.setVersion("0.1");
        settings.setFullScreen(false);
        settings.setIntroEnabled(false);
        settings.setMenuEnabled(true);
        settings.setProfilingEnabled(true);
        settings.setApplicationMode(ApplicationMode.DEVELOPER);

        settings.addServiceType(new ServiceType<SceneFactory>() {
            @Override
            public Class<SceneFactory> service() {
                return SceneFactory.class;
            }

            @Override
            public Class<? extends SceneFactory> serviceProvider() {
                return MySceneFactory.class;
            }
        });
    }

    public static class MySceneFactory extends SceneFactory {

        @Override
        public FXGLMenu newMainMenu(@NotNull GameApplication app) {
            return new GTAVMenu(app, MenuType.MAIN_MENU);
        }

        @Override
        public FXGLMenu newGameMenu(@NotNull GameApplication app) {
            return new GTAVMenu(app, MenuType.GAME_MENU);
        }
    }
Clone this wiki locally