Game update cycle
Before we jump straight into some coding action, let's first take a look at a couple of core classes that will make our lives easier. When you created your project with the setup tool, the core of the game, the MyGDXGame
class, which is the default name of the class, extends a class called ApplicationAdapter
. This in turn implements an interface called ApplicationListener
. Now, you might think these are good enough for us to get going; however, there is a better class that we can extend and that is the Game
class.
What is so special about this class? Essentially, it is ApplicationListener
that delegates the game to a screen. Every bar method, such as onCreate()
, is implemented. This will save us lots of time going forward.
The following code is the Game
class from the LibGDX framework:
public abstract class Game implements ApplicationListener { protected Screen screen; @Override public void dispose () { if (screen != null) screen.hide(); } @Override ...