0

I'm working on an android project in LibGDX which I mainly test using the DesktopLauncher. I have some UI, set using Scene2d elements. They look great on Desktop, but really off using an emulated nexus 7. How can I make them scale correctly and have the same position as on Desktop?

Thing is, I've set a button , for example, to have position x=300, y=200. While this looks good on Desktop, it differs on mobile. How can I scale them in such a way that the positions are the same, no matter the resolution?

I've found online about viewports, but they didn't help.

1
  • show your code, what you've done yet ?
    – AAryan
    Apr 30, 2017 at 18:32

1 Answer 1

0

I have managed to find an answer. For all those who might have this issue in the future, I solved the problem using this guide

https://github.com/libgdx/libgdx/wiki/Viewports

On top of that, what fixed my issue was setting

viewport.apply(true);

The parameter centers the camera, that solved my issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.