The Lifecycle of a Game

Libgdx has a minimalistic way of implementing a game that can have multiple levels. We first start with the Game class.

The Game class has a create() method that is called by Libgdx when the game starts up. You will want to set things up in this method. Mainly, you’ll want to create some State for your game and set a Screen to be shown.

The Game class also has a render() method, which gets called once every X amount of milliseconds. In this method you will want to check the current state of the game and change the Screen if necessary.

Screen is very similar to Game, but it’s job is to draw things on the screen. Game mainly manages which screen is currently drawing. Screen has two very important methods, Screen(), it’s constructor, and render().

Both of these classes will have render() methods that get called frequently, so you can think of a loop that is constantly called render() and making the instructions inside of it run. Game is constantly checking for whether it should set a new Screen to draw things. On the other hand, the current active Screen is constantly checking whether it should draw something different on for the person playing.

These two classes make up the basics of a Game’s lifecycle.

Video Lesson