The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

i´m feeling dumb, but i cannot place a simple panel at the bottom left of the screen.

I´m using a Control node (simple control, no container or anything), and i resize it every time with $Control.rect_size=OS.get_real_window_size() so that it is always of the same dimension of the screen.

Now, as a children of this control there is a 100x100 pixel panel.
In the editor of this panel, I set Top and Bottom anchor=1 while left and right =0. Doing so the anchor of the panel is at the bottom left of the screen.
Then i set the margins to 0 for left and bottom, Top=-100, Right=100.

Now if I look to the vertical positioning only, the panel bottom should lay at the bottom of the screen (0 pixel from the anchor) while the top of the panel should be 100 pixel above (-100 from the anchor).


Somehow the panel top is around 50 pixel above the bottom of the screen.
I´m saying around because no matter what property i track (position, anchor, margin), everything has the right value and should place the panel in the right position, but i can clearly see the panel is not a square but a rectangle.
I´m getting crazy, please help!

can it be that the getrealwindows_size() include the dimension of the window borders and this offsets everything?
That was exactly the problem, the right function is get_window_size() without real (but this function is not displayed in the helper)

in Engine by (1,514 points)
edited by

Instead of resizing your Control try using Layout -> Full Rect. Layout is available in the same menu as Select Mode/Pan Mode if any Control Node is selected.

Thanks! I thought layout only placed the control in a position and then didnt update it in game, that's much easier!

1 Answer

0 votes
Best answer

To make the first control cover the screen, you don't need code in the first place.
Select the first control, and in the Layout menu, choose Fullscreen. It will setup the anchors so that it will always fill up the parent area, in your case the screen (if there is no parent control).

Then to place a child control at the bottom left, either use the Layout menu again, or do what you just did already.

by (29,360 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.