Scenes and SceneManager
A scene sets up its environment and delegates game behavior to other objects.
SceneConfig describes the scene’s key, class, assets, layout, and FSM. Block Puzzle defines its game scene in this configuration. scene.config.ts
import { GameScene } from '../../GameScene';
import { GameFsm } from './fsm.config';
import type { SceneConfig } from '@gamedevland/engine/core';
export class GameSceneDefinition {
static readonly config: SceneConfig = {
key: 'game',
useClass: GameScene,
layout: 'json/layouts/scenes/game/layout.json',
fsm: GameFsm.config,
};
}
BaseScene provides a shared lifecycle. FsmDrivenScene adds ready and update events so the FSM can manage the game flow.
SceneConfig.assets.- Creates the scene DI container and builds the layout
- Prepares the configurations and starts services
- Activates components and starts the FSM if configured
- Calls
create(). InFsmDrivenScene, this method sendsSceneReady.
In the public project, GameScene simply passes the configuration to its base class. Piece placement logic lives elsewhere.
Scene transitions
SceneManager.start(key) opens the initial scene. replace(key, options) replaces the top scene, push adds a scene to the stack, and pop removes the top one. Only the top scene updates, and only while it is unpaused. Transitions run through a queue, and lifecycle hooks have a timeout.
Pass input to the new scene through options.params. A command reads it from sceneParams and validates it with decodeSceneParams. Transition parameters are separate from the current session state.