A libGDX application has a well defined life-cycle, governing the states of an application, like creating, pausing and resuming, rendering and disposing the application.

ApplicationListener

ApplicationListener interface and passing an instance of that implementation to the Application implementation of a specific back-end (see The Application Framework). From there on, the Application will call the ApplicationListener every time an application level event occurs. A bare-bones ApplicationListener implementation may look like this:

  1. public class MyGame implements ApplicationListener { public void create () { } public void render () { } public void resize (int width, int height) { } public void pause () { } public void resume () { } public void dispose () { }}

ApplicationAdapter class if not all interface methods are of relevance. Application, the ApplicationListener methods will be called as follows: The following diagram illustrates the life-cycle visually:

Where is the main loop?

ApplicationListener.render() method can be regarded as the body of such a main loop.

See also

libGDX and Android lifecycle if you are aiming for Android. The article also explains why you should not use static variables. Prev | Next