Is it possible and practical to have only one screen, like a GameScreen class, where the menu, getting ready (plus instructions), hud (only score) and game-over screens can pop-up when needed. Can I do this with the Table class from libGDX?

I'm asking this because I am working on a game where I would like to have the game-world in the background of the menu for game over etc. It's a 2D side-scrolling game, something like Flappy Bird or Swing Copters. I don't need the menu to be on a completely different screen! :D

Swing Copters


2 Answers 2


You should probably take a look at Scene2D's Window class. Think of it as a screen that just overlays other screens. It's also a Table, which means you can add buttons or any other Actor to it just like any other table. This also means you can directly add it to your Stage, if you wish.

A simple pause screen would be something like this:

Window pause = new Window("Paused", skin);
pause.setMoveable(false); //So the user can't move the window
pause.add(new TextButton("Unpause", skin)); //Add a new text button that unpauses the game.
pause.pack(); //Important! Correctly scales the window after adding new elements.
float newWidth = 400, newHeight = 200;
pause.setBounds((Gdx.graphics.getWidth() - newWidth ) / 2,
(Gdx.graphics.getHeight() - newHeight ) / 2, newWidth , newHeight ); //Center on screen.

and would turn out like this:

Example image


Yes. It is possible.

Any of the scene2dUI widgets, like Table, inherit from Actor. Actor has a setVisible(boolean isVisible) member that will hide it and all of its children and disable any touch events to it. You just have to make sure that your menu or game instructions are in front of your Game view by adding them to your Stage last.

You will also need to make sure that you pause any game logic that should not take place while the menu is visible. This can be done with just a boolean isPaused flag that your game engine checks before it does any position updating. If your game has animations that you still want to use while the menu is up, you will need to make sure that the isPaused flag doesn't prevent the animations from updating.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .