Hey guys!
I’m having this weird problem where a Table’s background can not be rendered, when it’s the root table. The table’s children’s backgrounds are rendered just fine, and when it’s not the root it also works. However, I’d very much like for this table to be the root - it should work, right?
I can’t anything in the docs about the root table’s background not rendering.
Here’s my code. It’s the gameOverTable’s background that doesn’t render:
gameOverTable = new Table(app.getUISkin());
guiStage.addActor(gameOverTable);
gameOverTable.setBackground(app.getUISkin().getDrawable("ui-bg"));
gameOverTable.pad(15f);
gameOverLabel = new Label("GAME OVER", app.getUISkin(), "gameOver");
gameOverTable.add(gameOverLabel).colspan(2).row();
score = new Label("SCORE: 0", app.getUISkin());
gameOverTable.add(score).colspan(2).space(10f).row();
TextButton mainButton = new TextButton("main menu", app.getUISkin());
mainButton.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
mainMenu();
}
});
mainButton.pad(10f);
gameOverTable.add(mainButton).fill().uniform().space(10f);
TextButton retryButton = new TextButton("retry", app.getUISkin());
retryButton.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
restart();
}
});
retryButton.pad(10f);
gameOverTable.add(retryButton).fill().uniform().space(10f);
gameOverTable.setX(app.getWidth()/2 - gameOverTable.getWidth()/2);
gameOverTable.setY(app.getHeight()/2 - gameOverTable.getHeight()/2);
…and here’s what that code looks like (the pink grid is the game behind. Also, the buttons use the same “ui-bg” Drawable for background).: