A scene being played, containing instances of objects rendered on screen.

Hierarchy (view full)

Constructors

Properties

networkId: null | string = null

A network ID associated to the scene to be used for multiplayer, to identify the scene across peers. A scene can have its networkId re-generated during the game, meaning that the scene is re-created on every peer.

pathfindingObstaclesManager: PathfindingObstaclesManager
physics2SharedData: null | Physics2SharedData
physics3DSharedData: null | Physics3DSharedData
tileMapCollisionMaskManager: TileMapRuntimeManager

Methods

  • Convert a point from the canvas coordinates (for example, the mouse position) to the container coordinates.

    Parameters

    • x: number

      The x position, in container coordinates.

    • y: number

      The y position, in container coordinates.

    • result: FloatPoint

      The point instance that is used to return the result.

    Returns FloatPoint

  • Convert a point from the container coordinates (for example, an object position) to the canvas coordinates.

    Parameters

    • sceneX: number

      The x position, in container coordinates.

    • sceneY: number

      The y position, in container coordinates.

    • result: FloatPoint

      The point instance that is used to return the result.

    Returns FloatPoint

  • Create objects from initial instances data (for example, the initial instances of the scene or the instances of an external layout).

    Parameters

    • data: InstanceData[]

      The instances data

    • xPos: number

      The offset on X axis

    • yPos: number

      The offset on Y axis

    • zPos: number

      The offset on Z axis

    • trackByPersistentUuid: boolean

      If true, objects are tracked by setting their persistentUuid to the same as the associated instance. Useful for hot-reloading when instances are changed.

    Returns void

  • Get the background color, as an hexadecimal number.

    Returns number

    The current background color.

  • Parameters

    • syncOptions: GetNetworkSyncDataOptions

    Returns null | LayoutNetworkSyncData

  • Load the runtime scene from the given scene.

    Parameters

    • sceneAndExtensionsData: null | SceneAndExtensionsData

      An object containing the scene data.

    Returns void

    See

    gdjs.RuntimeGame#getSceneAndExtensionsData

  • Should be called when the canvas where the scene is rendered has been resized. See gdjs.RuntimeGame.startGameLoop in particular.

    Returns void

  • Called when a scene is "paused", i.e it will be not be rendered again for some time, until it's resumed or unloaded.

    Returns void

  • Called when a scene is "resumed", i.e it will be rendered again on screen after having being paused.

    Returns void

  • Step and render the scene.

    Parameters

    • elapsedTime: number

      In milliseconds

    Returns boolean

    true if the game loop should continue, false if a scene change/push/pop or a game stop was requested.

  • Request a scene change to be made. The change is handled externally (see gdjs.SceneStack) thanks to getRequestedChange and getRequestedScene methods.

    Parameters

    • change: SceneChangeRequest

      One of RuntimeScene.CONTINUE|PUSH_SCENE|POP_SCENE|REPLACE_SCENE|CLEAR_SCENES|STOP_GAME.

    • Optional sceneName: string

      The name of the new scene to launch, if applicable.

    Returns void

  • Check if the scene was just resumed. This is true during the first frame after the scene has been unpaused.

    Returns boolean

    true if the scene was just resumed

  • Change the background color, by setting the RGB components. Internally, the color is stored as an hexadecimal number.

    Parameters

    • r: number

      The color red component (0-255).

    • g: number

      The color green component (0-255).

    • b: number

      The color blue component (0-255).

    Returns void

  • Set whether the canvas should be cleared before this scene rendering. This is experimental: if possible, try to avoid relying on this and use custom objects to build complex scenes.

    Parameters

    • shouldClearCanvas: boolean

    Returns void

  • Set the function called each time the scene is stepped. The function will be passed the runtimeScene as argument.

    Note that this is already set up by the gdjs.RuntimeScene constructor and that you should not need to use this method.

    Parameters

    • func: (() => void)

      The function to be called.

        • (): void
        • Returns void

    Returns void

  • Set the function called each time the scene is stepped to be the events generated code, which is by convention assumed to be a function in gdjs with a name based on the scene mangled name.

    Parameters

    • sceneData: LayoutData

      The scene data, used to find where the code was generated.

    Returns void

  • Start a new profiler to measures the time passed in sections of the engine in the scene.

    Parameters

    • onProfilerStopped: ((oldProfiler) => void)

      Function to be called when the profiler is stopped. Will be passed the profiler as argument.

        • (oldProfiler): void
        • Parameters

          Returns void

    Returns void