本文整理汇总了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));
});
}
示例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);
}
});
}
示例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("");
}
};
}
示例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("");
}
};
}
示例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);
}
});
}
示例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);
}
});
}