Skip to content

Application

Open Javadoc

Lifecycle

  1. Initialization
  2. Input handling
  3. Updating
  4. Rendering
  5. Disposal

Creating an application

There are 3 different ways to create an application.

Option 1: Extending Application class

public class MyApplication extends Application {
public MyApplication() {
super("Hello world", 900, 600);
}
}

Option 2: Instancing Application class

Application myApplication = new Application("Hello world", 900, 600);

Option 3: Using ApplicationBuilder

The application builder is an implementation of the builder pattern. It allows you to construct an application step by step.

ApplicationBuilder applicationBuilder = new ApplicationBuilder();
applicationBuilder.setTitle("Hello world").setWindowSize(900, 600);
Application myApplication = applicationBuilder.build();

Running an application

The run() method initializes the application and then starts it. This method will also catch any exceptions and log them.

myApplication.run();

Pausing and resuming an application

Pausing an application changes its state to PAUSED and sets the time scale to 0f.

myApplication.pause();
myApplication.resume();
// Or
myApplication.togglePause();
myApplication.togglePause();

Stopping an application

Calling the stop() method will safely terminate the application after the current frame has finished.

myApplication.stop();