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

Create a layer

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

Layers are a set of entities with certain characteristics that provide both logical and visual separation between parts of the game.

Set Up

To create a layer, we create a JSON file and add it to the 'entities' folder of the configuration with the filename that we want to refer to it by in the code. Once that is in place, we can start editing the layer's JSON definition. Here we add all the components that we want to make up the layer. Layers typically contain an EntityContainer and various handlers like HandlerLogic and HandlerRender. It may look something like this:

{
    "id": "action-layer",
    "components": [
        {"type": "HandlerLogic"},
        {"type": "HandlerCollision"},
        {
           "type": "Camera",
           "width": 3200 
        },
        {"type": "HandlerRender"},
        {"type": "HandlerController"},
        {"type": "EntityContainer", 
            "entities": [{"type": "collectible-manager"}]
        },
        {"type": "TiledLoader"}
    ]
}

The layer automatically sends a "tick" event to all of its components when it receives it from the Scene.

Clone this wiki locally