Managing multiple screens
We will now make some minor changes to our current class diagram to reflect the support for multiple screens that we want to add to our game.
Note
You might want to take a peek at the previous class diagram of Canyon Bunny for a quick refresher. See Chapter 3, Configuring the Game, for the diagram.
Take a look at the following updated class diagram:
What has been changed here is that CanyonBunnyMain
no longer implements the ApplicationListener
interface that is used by LibGDX to control the flow of the application. Instead, CanyonBunnyMain
now extends LibGDX's Game
class, which in turn implements the ApplicationListener
interface. The Game
class provides a setScreen()
method. Calling this method allows us to change the current screen to another one.
Every screen that we want to have in our game is encapsulated in a separate class and ends with *Screen
. This is just a naming convention in this project and you are free to do it differently, of course. There are...