I’m attempting to render a GUI in LibGDX on top of my game. I have a container table, and then two separate tables that I would like to render. One goes in the top left, the other in the bottom left. However, they will only render in the middle and I’m not sure what I’m doing wrong.
stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
stage.setCamera(controller.getCamera());
uiSkin = new Skin(Gdx.files.internal("res/gui/skin/uiskin.json"));
Table container = new Table(uiSkin);
Table infoTable = new Table(uiSkin);
Table chatTable = new Table(uiSkin);
container.debug();
infoTable.debug();
chatTable.debug();
container.setFillParent(true);
// Add the tables to the container table
container.add(chatTable).bottom().left().pad(10);
container.row();
container.add(infoTable).top().left().pad(10);
stage.addActor(container);
// Set up our chat table
chatTable.setFillParent(false);
chatTable.setWidth(300);
chatTable.setHeight(400);
// Set up the information Table
infoTable.setFillParent(false);
infoTable.setWidth(300);
infoTable.setHeight(500);
lblChatLabel = new Label("", uiSkin);
lblChatLabel.setWrap(true);
// Information Table Actors
lblPilotName = new Label(pilotName, uiSkin);
lblLocationInfo = new Label(locationInfo, uiSkin);
lblCreditsOnShip = new Label(creditsOnShip, uiSkin);
lblCreditsInBank = new Label(creditsInBank, uiSkin);
final ScrollPane scroll = new ScrollPane(lblChatLabel, uiSkin);
txtChatBar = new TextField("do a chat", uiSkin);
txtChatBar.setName("txtChatBar");
// Populate the Chat Table
chatTable.add(txtChatBar).expandX();
chatTable.row();
chatTable.add(scroll).expand().fill().colspan(4);
// Populate the Information Table
infoTable.add(lblPilotName);
infoTable.row();
infoTable.add(lblLocationInfo);
infoTable.row();
infoTable.add(lblCreditsOnShip);
infoTable.row();
infoTable.add(lblCreditsInBank);
And here a picture of the result. Even though I declared the width to be 300, the debug lines show that the table’s width is certainly not 300. Also, within the container there only appears to be one table, not two (infoTable and chatTable). Any ideas are much appreciated!