Reputation: 85
Can someone explain me how Stage and Table work in Libgdx. How to set stage to take the whole screen and how to put buttons in table one below other. Whatever I do, it all goes one button over the other.
Upvotes: 0
Views: 1722
Reputation: 8584
I think it's a valid question, since most answers on this site are documented either by the official documents or somewhere else. The two questions are very related so I that is fine by me too. I do however agree that the OP could have done a bit more digging to find the answer himself.
To answer your question:
The stage already takes the whole screen. It represents your screen by it's viewport. To have a table fill the screen you do table.setFillParent(true);
and add it to the stage. The stage will be the parent in this case and it will extend the table to it. The table becomes a root of the stage, a stage can have multiple roots.
If you are adding actors to a table and you want a new row you can do table.row()
or table.add(myActor).width(xxx).height(yyy).row()
to have it in a single line. After row you cannot chain anything since row returns void.
Upvotes: 5