FXGL icon indicating copy to clipboard operation
FXGL copied to clipboard

getAppWidth/getAppHieght have margins in ui

Open milimetron opened this issue 4 years ago • 1 comments

When spawning objects in the either the right or bottom edges of the ui (meaning using either getAppWidth or getAppHieght) the objects are placed either slightly away from the edge in case of the right or be slightly below the window in case of the bottom. This was tested with the official pong tutorial app( see included images), as well as personal apps ( see included code).

To Reproduce you can do one of the following:

  1. Run the pong example
  2. Use the following code( if needed i have other examples with the same results):

` @Spawns("border") public Entity createBorder(SpawnData data){

    Path path = new Path();

    path.setStroke(Color.RED);
    path.setStrokeWidth(TILE_SIZE); // In my code 30 but could be any value

    ObservableList<PathElement> elements = path.getElements();

    // Sets Start point
    elements.add(new MoveTo(0,0));

    // Creates border lines
    HLineTo top = new HLineTo(getAppWidth()-(TILE_SIZE/2));
    VLineTo right = new VLineTo(getAppHeight()-(TILE_SIZE/2));

    HLineTo bottom = new HLineTo(0);
    VLineTo left = new VLineTo(0);

    // Actually adds the lines
    elements.add(top);
    elements.add(right);
    elements.add(bottom);
    elements.add(left);

    return entityBuilder(data)
            .type(EntityType.BRICK)
            .viewWithBBox(path)
            .collidable()
            .zIndex(-1)
            .build();

}

`

See the right paddle's margin compared to the left

Screenshot from 2021-07-13 09-03-48

Ubuntu 20.04.2 LTS 64-bit

milimetron avatar Jul 13 '21 06:07 milimetron

Thanks for this. I suspect this is an issue related to window handling on Linux as I recall similar problems in the past. I will see if I can reproduce this in a pure JavaFX app, in which case that will suggest the issue comes from JavaFX, rather than FXGL.

AlmasB avatar Jul 14 '21 12:07 AlmasB