I'm making an RTS game and I want to have a similar UI to Ages of Empires with the UI at the bottom. I have difficulties setting the background of the Table that holds the specific elements.
I tried a lot of things, like:
- setBackground() with Color
- setBackground() with an image from the skin
- using a custom solution found here: Libgdx | Scene2d | Set background color of table?
but nothing seems to work. I think the problem is that I try to apply the background color to the back-most table that holds other tables. I can set color for the front tables, but not for the main, back one.
Here is where I draw the UI:
skin = new Skin(Gdx.files.internal("core/assets/skinComposerExport/uiskin.json"));
stage = new Stage(new ScreenViewport());
mainTable = new Table(skin);
unitInfoTable = new Table(skin);
unitSpecTable = new Table(skin);
className = new Label("Placeholder scnm", skin);
...
abilityCD = new Label("Placeholder acdn", skin);
mainTable.setPosition(Gdx.graphics.getWidth() / 2.0f, 0);
mainTable.center().bottom();
mainTable.setBackground("UI_background");
addLabelsToTable(unitInfoTable, className, hitPoints, mana, dmg, range);
addLabelsToTable(unitSpecTable, abilityName, abilityMana, abilityDmg, abilityRange, abilityCD);
mainTable.add(unitInfoTable).padRight(20);
mainTable.add(unitSpecTable);
stage.addActor(mainTable);
I want the whole bottom of the screen to be white (about 200px tall and fill the whole x axis) and draw elements on it, but I can not set the background color.