当前位置: 首页>>代码示例>>Java>>正文


Java GameApplication类代码示例

本文整理汇总了Java中com.almasb.fxgl.app.GameApplication的典型用法代码示例。如果您正苦于以下问题:Java GameApplication类的具体用法?Java GameApplication怎么用?Java GameApplication使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GameApplication类属于com.almasb.fxgl.app包,在下文中一共展示了GameApplication类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: FXGLMenu

import com.almasb.fxgl.app.GameApplication; //导入依赖的package包/类
public FXGLMenu(GameApplication app, MenuType type) {
    this.app = app;
    this.type = type;
    this.listener = (MenuEventHandler) app.getMenuListener();

    getContentRoot().getChildren().addAll(
            createBackground(app.getWidth(), app.getHeight()),
            createTitleView(app.getSettings().getTitle()),
            createVersionView(makeVersionString()),
            menuRoot, contentRoot);

    // we don't data-bind the name because menu subclasses
    // might use some fancy UI without Text / Label
    listener.profileNameProperty().addListener((o, oldName, newName) -> {
        if (!oldName.isEmpty()) {
            // remove last node which *should* be profile view
            getContentRoot().getChildren().remove(getContentRoot().getChildren().size() - 1);
        }

        getContentRoot().getChildren().add(createProfileView("Profile: " + newName));
    });
}
 
开发者ID:AlmasB,项目名称:FXGL,代码行数:23,代码来源:FXGLMenu.java

示例2: CCTRMenu

import com.almasb.fxgl.app.GameApplication; //导入依赖的package包/类
public CCTRMenu(GameApplication app, MenuType type) {
    super(app, type);

    Node menuBody = type == MenuType.MAIN_MENU
            ? createMenuBodyMainMenu()
            : createMenuBodyGameMenu();

    contentRoot.setTranslateX(app.getWidth() / 2 - 50);
    contentRoot.setTranslateY(app.getHeight() / 2 - 100);

    menuRoot.getChildren().add(menuBody);
    contentRoot.getChildren().add(EMPTY);

    activeProperty().addListener((observable, wasActive, isActive) -> {
        if (!isActive) {
            // the scene is no longer active so reset everything
            // so that next time scene is active everything is loaded properly
            switchMenuTo(menuBody);
            switchMenuContentTo(EMPTY);
        }
    });
}
 
开发者ID:AlmasB,项目名称:FXGL,代码行数:23,代码来源:CCTRMenu.java

示例3: newMainMenu

import com.almasb.fxgl.app.GameApplication; //导入依赖的package包/类
@NotNull
@Override
public FXGLMenu newMainMenu(@NotNull GameApplication app) {
    return new FXGLDefaultMenu(app, MenuType.MAIN_MENU) {
        @Override
        protected Node createBackground(double width, double height) {
            return FXGL.getAssetLoader().loadTexture("custom_bg.png");
        }

        @Override
        protected Node createTitleView(String title) {
            return new Text("");
        }
    };
}
 
开发者ID:AlmasB,项目名称:FXGL,代码行数:16,代码来源:CustomMenuBackgroundSample.java

示例4: newGameMenu

import com.almasb.fxgl.app.GameApplication; //导入依赖的package包/类
@NotNull
@Override
public FXGLMenu newGameMenu(@NotNull GameApplication app) {
    return new FXGLDefaultMenu(app, MenuType.GAME_MENU) {
        @Override
        protected Node createBackground(double width, double height) {
            return FXGL.getAssetLoader().loadTexture("custom_bg.png");
        }

        @Override
        protected Node createTitleView(String title) {
            return new Text("");
        }
    };
}
 
开发者ID:AlmasB,项目名称:FXGL,代码行数:16,代码来源:CustomMenuBackgroundSample.java

示例5: FXGLDefaultMenu

import com.almasb.fxgl.app.GameApplication; //导入依赖的package包/类
public FXGLDefaultMenu(GameApplication app, MenuType type) {
    super(app, type);

    MenuBox menu = type == MenuType.MAIN_MENU
            ? createMenuBodyMainMenu()
            : createMenuBodyGameMenu();

    double menuX = 50;
    double menuY = app.getHeight() / 2 - menu.getLayoutHeight() / 2;

    menuRoot.setTranslateX(menuX);
    menuRoot.setTranslateY(menuY);

    contentRoot.setTranslateX(menuX * 2 + 200);
    contentRoot.setTranslateY(menuY);

    menuRoot.getChildren().add(menu);
    contentRoot.getChildren().add(EMPTY);

    activeProperty().addListener((observable, wasActive, isActive) -> {
        if (!isActive) {
            // the scene is no longer active so reset everything
            // so that next time scene is active everything is loaded properly
            switchMenuTo(menu);
            switchMenuContentTo(EMPTY);
        }
    });
}
 
开发者ID:AlmasB,项目名称:FXGL,代码行数:29,代码来源:FXGLDefaultMenu.java

示例6: GTAVMenu

import com.almasb.fxgl.app.GameApplication; //导入依赖的package包/类
public GTAVMenu(GameApplication app, MenuType type) {
    super(app, type);

    menuBody = type == MenuType.MAIN_MENU
            ? createMenuBodyMainMenu()
            : createMenuBodyGameMenu();

    vbox.getChildren().addAll(new Pane(), new Pane());
    vbox.setTranslateX(50);
    vbox.setTranslateY(50);

    contentRoot.setTranslateX(280);
    contentRoot.setTranslateY(130);

    menuRoot.getChildren().add(vbox);
    contentRoot.getChildren().add(EMPTY);

    vbox.getChildren().set(0, makeMenuBar());

    activeProperty().addListener((observable, wasActive, isActive) -> {
        if (!isActive) {
            // the scene is no longer active so reset everything
            // so that next time scene is active everything is loaded properly
            switchMenuTo(menuBody);
            switchMenuContentTo(EMPTY);
        }
    });
}
 
开发者ID:AlmasB,项目名称:FXGL,代码行数:29,代码来源:GTAVMenu.java


注:本文中的com.almasb.fxgl.app.GameApplication类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。