Application
Open JavadocLifecycle
Section titled “Lifecycle”- Initialization
- Input handling
- Updating
- Rendering
- Destruction
Creating an application
Section titled “Creating an application”There are 3 different ways to create an application.
Option 1: Extending Application
class
Section titled “Option 1: Extending class”public class MyApplication extends Application {
public MyApplication() { super("Hello world", 900, 600); }
}
Option 2: Instancing Application
class
Section titled “Option 2: Instancing class”Application myApplication = new Application("Hello world", 900, 600);
Option 3: Using ApplicationBuilder
Section titled “Option 3: Using ”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
Section titled “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
Section titled “Pausing and resuming an application”Pausing an application changes its state to PAUSED
and sets the time scale to 0f
.
myApplication.pause();myApplication.resume();// OrmyApplication.togglePause();myApplication.togglePause();
Stopping an application
Section titled “Stopping an application”Calling the stop()
method will safely terminate the application after the current frame has finished.
myApplication.stop();