Skip to content
This repository has been archived by the owner on Apr 15, 2022. It is now read-only.

Create a Scene

Derek Detweiler edited this page Aug 16, 2017 · 3 revisions

Scenes are objects loaded by the Game when the game starts. They are the discrete logical phases of the game (e.g. main menu, level 1, level 2). Only one scene is loaded at a time.

To construct a scene, create a JSON file. Then add the scene to the 'scenes' folder of the configuration. The file name is an id by which we will refer to this scene in the rest of the game. Once done, we can begin filling in the scene JSON file. In the JSON file we set what layers we want this scene to load. The scene will pass the Game ticks to all of the loaded layers.

Below is an example 'scene-layer-1.json' file:

{
    "layers":[{
        "type": "action-layer",
            "properties": {
                "level": "level-1"
            }
        },
        {"type": "interface-layer"}
    ]
}

Once you've added all the layers into the file your scene is ready to be loaded.

To set the first scene that is loaded, you can set state in main.js under the application options as shown here:

    app = new Application({
        name: "PlatypusGame",
        canvasId: "stage",
        configPath: "assets/config/config.json",
        display: Display,
        state: "first-scene-to-load"
    })
Clone this wiki locally