dacha
    Preparing search index...

    Class Scene

    A scene represents a distinct game level, menu, or gameplay state within the game world.

    Scenes serve as the primary organizational unit in the engine architecture. Each scene contains a collection of actors that can be accessed and managed directly or through utilitiy classes such as the ActorQuery.

    Scenes are typically created from configuration data rather than instantiated directly. SceneManager reads scene configurations and creates scene instances with their associated actors automatically.

    Hierarchy (View Summary)

    Index
    • Creates a new scene instance.

      Parameters

      • options: SceneOptions

      Returns Scene

    actorSpawner: ActorSpawner

    Spawner utility for creating new actors within this scene

    children: Actor[]

    Collection of actors contained within this scene

    data: Record<string, unknown>

    Custom data storage for scene-related information

    id: string

    Id of the entity

    name: string

    Name of the entity

    parent: null

    Parent of the entity

    templateCollection: TemplateCollection

    Template collection used for creating actors from predefined templates

    • Adds an event listener to the event target.

      Type Parameters

      Parameters

      • type: T

        Type of event to listen for

      • callback: SceneObjectListenerFn<T>

        Function to call when the event is triggered

      Returns void

    • Adds a child to the entity.

      Parameters

      • child: Actor

        Child to add

      Returns void

    • Dispatches an event to the event target.

      Events are processed in the engine event queue at the beginning of each frame in order that they were dispatched.

      Type Parameters

      Parameters

      • type: T

        Type of event to dispatch

      • ...payload: EventPayload<SceneEventMap, T>

        Payload of the event

      Returns void

    • Dispatches an event to the event target immediately.

      Events are processed immediately and not added to the engine event queue.

      Type Parameters

      Parameters

      • type: T

        Type of event to dispatch

      • ...payload: EventPayload<SceneEventMap, T>

        Payload of the event

      Returns void

    • Finds a child entity by a predicate function.

      Parameters

      • predicate: (child: Actor) => boolean

        A function that runs on each child entity and should return true if the child entity matches the predicate or false otherwise

      • recursive: boolean = true

        Whether to search recursively through the children

      Returns Actor | undefined

      Child entity or undefined

    • Finds a child entity by its id.

      Parameters

      • id: string

        Id of the child entity

      • recursive: boolean = true

        Whether to search recursively through the children

      Returns Actor | undefined

      Child entity or undefined

    • Finds a child entity by its name.

      Parameters

      • name: string

        Name of the child entity

      • recursive: boolean = true

        Whether to search recursively through the children

      Returns Actor | undefined

      Child entity or undefined

    • Removes the entity from its parent.

      Returns void

    • Removes all event listeners from the event target.

      Returns void

    • Removes a child from the entity.

      Parameters

      • child: Actor

        Child to remove

      Returns void

    • Removes an event listener from the event target.

      Type Parameters

      Parameters

      • type: T

        Type of event to remove the listener for

      • callback: SceneObjectListenerFn<T>

        Function to remove the listener for

      Returns void