问题
I'm building a menu for my game and I'm stuck.
When I position a Container with it's setPosition
function and add a Button to the container with setFillParent
set to true
the button's position isn't set to the same position as the container.
The button size matches the size of the Container but its position is wrong. When I don't set setFillParent
to true
the position of the button within the container is right but the size is wrong.
Here is the code, pretty simple:
Container container = new Container(exitButton);
exitButton.setFillParent(true/false);
Here is an image that ilustrate this, left image has setFillParent set to true and the right image does not.
The green hightlight on the image is the container
, the [X] image is the exitButton
.
回答1:
Ok, I figured it out, calling container.fill()
before setting the containers size and position somehow solves the problem. No idea why, but it solves it.
来源:https://stackoverflow.com/questions/43958162/having-problems-with-the-layout-widget-container-in-libgdx