Вёрстка сцены01 / 15

Экран сцены из JSON

Опишем поле и счётчик в layout.json.

В SceneConfig.layout укажем путь к JSON. В type запишем тип элемента, в props его настройки, а в children вложенные элементы. Пример сокращён. 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 · счёт
  • gameplay · игровая область
    • board · поле

Источники ↗

Block Puzzle · layout.json↗Полный layout Block Puzzle.