How do I create a triangle with Java FXGL

113 Views Asked by At

Hey so im new to FXGL and I followed some tutorials to create a small game. They have created rectangles and circles like this:

@Spawns("player")
public Entity newPlayer(SpawnData data) {
    var body = new Circle(25, Color.LIGHTBLUE);
    body.setStroke(Color.GRAY);

    return entityBuilder()
            .type(Entities.PLAYER)
            .from(data)
            .viewWithBBox(body)
            .collidable()
            .build();
}

and like this:

@Spawns("projectile")
public Entity newProjectile(SpawnData data) {
    var view = new Circle(10, Color.LIGHTBLUE);
    view.setStroke(Color.GRAY);

    return entityBuilder()
            .type(Entities.PROJECTILE)
            .from(data)
            .viewWithBBox(view)
            .collidable()
            .build();
}

And I was thinking, is there a way to create triangles in some sort of similar way?

0

There are 0 best solutions below