A scene is designed to be a single screen in your game. For example, you might have a loading Scene, a menu Scene, etc.

Creating a Scene

Scenes are subclasses of a class template called Scene<T>. To create your Scene class you must do the following:

Here's an example:

class MyScene : public Scene<MyScene> {
    MyScene(Window* window):
        Scene<MyScene>(window) {}

    void load();

You can then register the Scene in your application's init() method:

    bool init() {
        return true;

Whichever Scene is registered with the name "main" is the first Scene instantiated when the application begins.

Scene Methods

You can override the following methods in your Scene class:

activate() and deactivate() are called when you change to a different scene.

Scene Management

Scenes are managed by the SceneManager, which is a property of Application. The application SceneManager is accessible directly from within a scene using the scenes property.

You can make a Scene current by calling SceneManager::activate(name, behaviour). This will do a number of things:

You have a lot of control over this process:

This means that you can (for example) create render pipelines that remain active even once the Scene has been deactivated, and use that to implement transitions etc.