Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getAppWidth/getAppHieght have margins in ui #1080

Open
milimetron opened this issue Jul 13, 2021 · 1 comment
Open

getAppWidth/getAppHieght have margins in ui #1080

milimetron opened this issue Jul 13, 2021 · 1 comment

Comments

@milimetron
Copy link

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

@AlmasB
Copy link
Owner

AlmasB commented Jul 14, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants