Search in sources :

Example 61 with Rectangle

use of javafx.scene.shape.Rectangle in project FXGL by AlmasB.

the class NoiseSample method initUI.

@Override
protected void initUI() {
    rect = new Rectangle(100, 100);
    rect.setTranslateX(350);
    Line l1 = new Line(0, Y_MAX, 500, Y_MAX);
    Line l2 = new Line(X_MAX, 0, X_MAX, 600);
    getGameScene().addUINodes(rect, l1, l2);
}
Also used : Line(javafx.scene.shape.Line) Rectangle(javafx.scene.shape.Rectangle)

Example 62 with Rectangle

use of javafx.scene.shape.Rectangle in project FXGL by AlmasB.

the class FXGLDefaultMenu method createBackground.

@Override
protected Node createBackground(double width, double height) {
    Rectangle bg = new Rectangle(width, height);
    bg.setFill(Color.rgb(10, 1, 1));
    return bg;
}
Also used : Rectangle(javafx.scene.shape.Rectangle)

Example 63 with Rectangle

use of javafx.scene.shape.Rectangle in project FXGL by AlmasB.

the class FXGLDefaultMenu method createTitleView.

@Override
protected Node createTitleView(String title) {
    Text text = FXGL.getUIFactory().newText(title, 50);
    Rectangle bg = new Rectangle(text.getLayoutBounds().getWidth() + 20, 60, null);
    bg.setStroke(Color.WHITE);
    bg.setStrokeWidth(2);
    StackPane titleRoot = new StackPane();
    titleRoot.getChildren().addAll(bg, text);
    titleRoot.setTranslateX(app.getWidth() / 2 - (text.getLayoutBounds().getWidth() + 20) / 2);
    titleRoot.setTranslateY(50);
    return titleRoot;
}
Also used : Rectangle(javafx.scene.shape.Rectangle) Text(javafx.scene.text.Text) StackPane(javafx.scene.layout.StackPane)

Example 64 with Rectangle

use of javafx.scene.shape.Rectangle in project FXGL by AlmasB.

the class RangeTest method onUpdate.

@Override
protected void onUpdate(double tpf) {
    List<Entity> list = getGameWorld().getEntitiesInRange(player.getBoundingBoxComponent().range(40, 40));
    list.forEach(e -> {
        if (e == markers)
            return;
        EntityView view = e.getComponent(ViewComponent.class).getView();
        view.getNodes().stream().map(n -> (Rectangle) n).forEach(r -> r.setFill(Color.YELLOW));
    });
    List<Entity> list2 = getGameWorld().getEntitiesCopy();
    list2.removeAll(list);
    list2.forEach(e -> {
        EntityView view = e.getComponent(ViewComponent.class).getView();
        view.getNodes().stream().map(n -> (Rectangle) n).forEach(r -> r.setFill(Color.BLACK));
    });
}
Also used : KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) Control(com.almasb.fxgl.entity.Control) Input(com.almasb.fxgl.input.Input) Rectangle(javafx.scene.shape.Rectangle) GameSettings(com.almasb.fxgl.settings.GameSettings) UserAction(com.almasb.fxgl.input.UserAction) Required(com.almasb.fxgl.entity.component.Required) List(java.util.List) PositionComponent(com.almasb.fxgl.entity.component.PositionComponent) ViewComponent(com.almasb.fxgl.entity.component.ViewComponent) Entities(com.almasb.fxgl.entity.Entities) EntityView(com.almasb.fxgl.entity.view.EntityView) GameApplication(com.almasb.fxgl.app.GameApplication) Entity(com.almasb.fxgl.entity.Entity) Entity(com.almasb.fxgl.entity.Entity) EntityView(com.almasb.fxgl.entity.view.EntityView) ViewComponent(com.almasb.fxgl.entity.component.ViewComponent) Rectangle(javafx.scene.shape.Rectangle)

Example 65 with Rectangle

use of javafx.scene.shape.Rectangle in project FXGL by AlmasB.

the class RangeTest method getMarker.

private Rectangle getMarker(double x, double y) {
    Rectangle rect = new Rectangle(40, 40, null);
    rect.setTranslateX(x);
    rect.setTranslateY(y);
    rect.setStroke(Color.RED);
    return rect;
}
Also used : Rectangle(javafx.scene.shape.Rectangle)

Aggregations

Rectangle (javafx.scene.shape.Rectangle)190 Point2D (javafx.geometry.Point2D)33 Text (javafx.scene.text.Text)28 Entity (com.almasb.fxgl.entity.Entity)27 Circle (javafx.scene.shape.Circle)20 Color (javafx.scene.paint.Color)18 HitBox (com.almasb.fxgl.physics.HitBox)16 Pane (javafx.scene.layout.Pane)16 Group (javafx.scene.Group)15 Node (javafx.scene.Node)14 PhysicsComponent (com.almasb.fxgl.physics.PhysicsComponent)12 Scene (javafx.scene.Scene)12 EntityView (com.almasb.fxgl.entity.view.EntityView)10 Label (javafx.scene.control.Label)10 List (java.util.List)8 Collectors (java.util.stream.Collectors)8 TextFlow (javafx.scene.text.TextFlow)8 CollidableComponent (com.almasb.fxgl.entity.component.CollidableComponent)7 Bounds (javafx.geometry.Bounds)7 KeyCode (javafx.scene.input.KeyCode)7