Game Development Reference
In-Depth Information
Take a look at the following updated class diagram:
abstract
Game
>>
interface
Screen
>>
CanyonBunnyMain
Assets
11
1
1
1
abstract
AbstractGameScreen
>>
*
1
11
CameraHelper
Screens
MenuScreen
GameScreen
1
1
1
1
1
1
WorldRenderer
WorldController
Level
11
1
abstract
AbstractGameObject
>>
*
BunnyHead
WaterOverlay Mountains
Rock
GoldCoin
Feather
Clouds
1
*
Player
Character
Level
Objects
Level
Items
Level
Decorations
Cloud
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 also three new classes shown in the
preceding diagram, which are AbstractGameScreen , MenuScreen , and GameScreen .
The menu and the game screen classes extend AbstractGameScreen so that we can
easily define the common actions that we want to be executed for all our screens.
Additionally, AbstractGameScreen implements LibGDX's Screen interface, which
introduces the show() and hide() method for each screen. These methods will be
called by Game and will take the place of create() and dispose() , so we will have
to move our existing code accordingly.
 
Search WWH ::




Custom Search