Building the scene for the menu screen
We will now begin with the actual implementation of the scene for the menu screen. First, take a look at the following diagram that shows the hierarchy of the UI scene graph that we are going to build step-by-step:
The scene graph starts with an empty Stage
. Then, the first child actor added to the stage is a Stack
widget. The Stack
widget allows you to add actors that can overlay other actors. We will make use of this ability to create several layers. Each layer uses a Table
widget as its parent actor. Using stacked tables enables us to lay out actors in an easy and logical way.
In the first step, we will add the basic structure of our stacked layers and some skeleton methods, which we are going to fill in the subsequent steps.
Add the following import lines to MenuScreen
:
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Actor...