use of com.almasb.fxgl.app.scene.GameSubScene in project FXGL by AlmasB.
the class EntitiesScenesSample method pushNewGameSubScene.
private void pushNewGameSubScene() {
// 3D = true
var scene = new GameSubScene(getAppWidth(), getAppHeight(), true);
var text = getUIFactoryService().newText("Sub Scene", Color.BLACK, 54);
text.setTranslateX(250);
text.setTranslateY(250);
text.setEffect(new DropShadow(5, 7.5, 3.5, Color.BLACK));
var player = entityBuilder().at(0, 0, -5).view(new Cuboid(1, 1, 1)).build();
animationBuilder().interpolator(Interpolators.EXPONENTIAL.EASE_OUT()).duration(Duration.seconds(2)).repeatInfinitely().autoReverse(true).translate(player).from(new Point3D(-3, 1, -11)).to(new Point3D(4, 0, 0)).buildAndPlay(scene);
scene.getGameScene().setBackgroundColor(Color.web("green", 0.3));
scene.getGameScene().addUINode(text);
scene.getGameWorld().addEntities(player);
getSceneService().pushSubScene(scene);
onKeyBuilder(scene.getInput(), KeyCode.F).onActionBegin(() -> pushNewGameSubScene());
onKeyBuilder(scene.getInput(), KeyCode.G).onActionBegin(() -> getSceneService().popSubScene());
}
Aggregations