We have our game, but you may be wondering why we haven't done anything with the lifecycle of the game, like we did with Snake. Well, that is because we are going to add new screens that will appear at the start and the end. But before we get on to creating and making the new screens, I want to talk about a really useful set of UI tools LibGDX offers for making UIs, Scene2D. Well, what is it?
According the LibGDX wiki page:
"Scene2d is a 2D scene graph for building applications and UIs using a hierarchy of actors."
At its core, Scene2d is made of three classes:
Actor
: This contains the position, size (rectangular only), origin, scale, rotation, and color.Group
: This is anActor
class that can contain other actors and children.Stage
: This class has aCamera
class, aSpriteBatch
class, and aGroup
class. It orchestrates the updating, drawing, and input handling for all the children in itsGroup
.
Of course, this wouldn't be LibGDX if it stopped there. There is a whole...