Game Development Reference
In-Depth Information
All the widgets currently available in Scene2D UI are
Button
,
ButtonGroup
,
CheckBox
,
Dialog
,
Image
,
ImageButton
,
Label
,
List
,
ScrollPane
,
SelectBox
,
Slider
,
SplitPane
,
Stack
,
Window
,
TextButton
,
TextField
,
TextArea
,
Touchpad
,
and
Tree
.
Scene2D UI also supports the easy creation of new custom widgets. We will discuss
a selected number of widgets as we implement them in our menu. For a complete
list and description of each widget, check out the official documentation at
https://
In addition to Scene2D UI, LibGDX also incorporates a separate project called
TableLayout
. The
TableLayout
object makes it very easy to create and maintain
dynamic (read: resolution-independent) layouts using tables. It also provides an
intuitive API. A
Table
class provides access to the functionality of
TableLayout
,
which is also implemented as a widget, and therefore integrates seamlessly into
the concept of Scene2D UI. It is highly recommended to check out the official
One more important feature of Scene2D UI is the support of skins. A skin is a
collection of resources used to style and display UI widgets, for example, resources
can be texture regions, fonts, and colors. Typically, a skin uses texture regions that
come from a texture atlas. The style definition of each widget is stored in a separate
file that uses the JSON file format. For more information, check out the official
Using LibGDX's scene graph for the
menu UI
We are now going to create the scene of the menu screen. The scene will feature a
background image that fills the whole screen. There will be logos in the top-left and
bottom-left corner of the screen and two clickable buttons anchored in the bottom-
right corner that will trigger either a play or an options action. A gold coin and a
huge image of the bunny head are also added to the scene.