-
Notifications
You must be signed in to change notification settings - Fork 0
Create a Scene
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' section of the game/config.json file. Here we give it an id by which we will refer to this scene in the rest of the game.
An example from the config.json file:
"scenes": [
{"id": "menu", "src": "scenes/menu.json"},
{"id": "scene-level-1", "src": "scenes/scene-level-1.json"},
{"id": "scene-level-2", "src": "scenes/scene-level-2.json"},
{"id": "scene-level-3", "src": "scenes/scene-level-3.json"}
]
Once we have added it to the config file, 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": "multitouch-interface-layer"},
{"type": "touch-interface-layer"},
{"type": "desktop-interface-layer"}
]
}
Once you've added all the layers into the file your scene is ready to be loaded. Scenes are loaded in the Game using
loadScene(sceneId, transition);
sceneId is the id of the scene in the config.json file. transition is the type of transition that should be made between scenes. The engine supports 'instant' and 'fade-to-black'.
If you want to set the first scene that is loaded, you can set initialScene in the global section in the config.json file to the id of the scene you want as described in Create-Config-JSON.
Platypus was developed by PBS KIDS and Gopherwood Studios. It is free to use (see licenses.txt), all assets in the example games are © Gopherwood Studios and/or © PBS KIDS.