Scene layout01 / 15

Building a scene from JSON

Describe the board and score display in layout.json.

Set SceneConfig.layout to the path to the JSON file. Use type for the element type, props for its settings, and children for nested elements. The example is shortened. layout.json

{
  "root": {
    "type": "Container",
    "children": {
      "score": { "type": "Text", "props": { "text": "0", "anchor": 0.5 } },
      "gameplay": {
        "type": "Container",
        "children": { "board": { "type": "Container" } }
      }
    }
  }
}
root Container
  • score · score
  • gameplay · play area
    • board · board

Sources ↗

Block Puzzle · layout.json↗The full Block Puzzle layout.