Ive made a method to create a text as how I want it. It works fine, but when I change the resolution, the HUD isnt at the position its supposed to be.
Is there an easy way to correct the position?
Have you tried setting the text size and position to a predefined percentage of the current screen size?
E.g:
//position will always be the center of the screen
float positionX = app.getContext().getSettings().getWidth() * 0.5f;
float positionY = app.getContext().getSettings().getHeight() * 0.5f;
Node myGui = new Node("myGui");
guiNode.attachChild(myGui);
float guiScale = scale calculated from screen size and 1980x1080 view size
myGui.setLocalScale(guiScale);
BitmapText yourText = ....
yourText.setLocalTranslation(location in 1980x1080 space)
myGui.attachChild(yourText);
Just do all of your screen setup in some theoretical view space and then scale it. Way less complicated.
You will still probably want to position things relative to a calculated width and height when you figure out that you want to deal with different aspect ratios. But that’s not so hard either.