Reference

Scene Files

Scene files use the .scene.php extension and return a PHP array describing the scene and its initial hierarchy.

Naming Convention

<scene-name>.scene.php

Example:

level01.scene.php

Top-Level Schema

<?php

use Sendama\Engine\Core\GameObject;

return [
    'name' => 'Level 1',
    'width' => 120,
    'height' => 25,
    'environmentTileMapPath' => 'Maps/level',
    'environmentCollisionMapPath' => 'Maps/level.collider',
    'hierarchy' => [
        [
            'type' => GameObject::class,
            'name' => 'Player',
            'tag' => 'Player',
            'position' => ['x' => 4, 'y' => 12],
            'rotation' => ['x' => 0, 'y' => 0],
            'scale' => ['x' => 1, 'y' => 1],
            'components' => [],
        ],
    ],
];

Top-Level Keys

Key Type Notes
name string Optional but strongly recommended
width int Logical scene width
height int Logical scene height
environmentTileMapPath string Background tile map path
environmentCollisionMapPath string Optional environment collision map path
hierarchy array Root object list

Hierarchy Entry Schema

Each item in hierarchy describes one object. It may be a GameObject or a supported UI element class.

Common keys:

Key Type Notes
type class-string Class to instantiate
name string Human-readable object name
tag string Optional logical tag
position array{x:int|float,y:int|float} Local position
rotation array{x:int|float,y:int|float} Local rotation
scale array{x:int|float,y:int|float} Local scale
sprite array Renderer sprite data
components array Attached component definitions
children array Nested child objects

UI-oriented objects may also define:

Key Type Notes
size array{x:int|float,y:int|float} UI size
text string Text or label content

Sprite Block

'sprite' => [
    'texture' => [
        'path' => 'Textures/player',
        'position' => ['x' => 0, 'y' => 3],
        'size' => ['x' => 1, 'y' => 1],
    ],
],
Key Type Notes
texture.path string Asset-relative texture path
texture.position array{x:int,y:int} Crop origin inside the texture
texture.size array{x:int,y:int} Crop size

Component Block

Scene component metadata is typically written like this:

'components' => [
    [
        'class' => MyGame\Scripts\PlayerController::class,
        'data' => [
            'speed' => 4,
        ],
    ],
],

Supported metadata keys for the property payload are:

  • data
  • properties
  • legacy typo proerties

The editor currently writes data.

Serializable fields can target:

  • public properties
  • non-public properties marked with #[SerializeField]

Nested Children

Children use the same schema as root hierarchy items:

'children' => [
    [
        'type' => GameObject::class,
        'name' => 'Weapon',
        'position' => ['x' => 1, 'y' => 0],
    ],
],

Child transforms are parent-relative at authoring time.

Path Rules

Common path forms:

  • Textures/player
  • Textures/player.texture
  • Maps/level
  • Maps/level.tmap
  • Prefabs/enemy.prefab.php

The runtime and editor both resolve asset-relative paths from the project asset root.