Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • RuntimeScene

Index

Methods

  • addLayer(layerData: LayerData): void
  • createNewUniqueId(): number
  • Create a new object from its name. The object is also added to the instances living on the scene ( No need to call RuntimeScene.addObject )

    Parameters

    • objectName: string

      The name of the object to be created

    Returns null | RuntimeObject

    The created object

  • createObjectsFrom(data: InstanceData[], xPos: number, yPos: number, trackByPersistentUuid: boolean): void
  • 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

    • 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

  • enableDebugDraw(enableDebugDraw: boolean, showHiddenInstances: boolean, showPointsNames: boolean, showCustomPoints: boolean): void
  • Activate or deactivate the debug visualization for collisions and points.

    Parameters

    • enableDebugDraw: boolean
    • showHiddenInstances: boolean
    • showPointsNames: boolean
    • showCustomPoints: boolean

    Returns void

  • Get a list of all gdjs.RuntimeObject living on the scene. You should not, normally, need this method at all. It's only to be used in exceptional use cases where you need to loop through all objects, and it won't be performant.

    Returns RuntimeObject[]

    The list of all runtime objects on the scnee

  • getAllLayerNames(result: string[]): void
  • Fill the array passed as argument with the names of all layers

    Parameters

    • result: string[]

      The array where to put the layer names

    Returns void

  • getBackgroundColor(): number
  • getInitialSharedDataForBehavior(name: string): null | BehaviorSharedData
  • Get the data representing the initial shared data of the scene for the specified behavior.

    Parameters

    • name: string

      The name of the behavior

    Returns null | BehaviorSharedData

    The shared data for the behavior, if any.

  • getInstancesCountOnScene(objectName: string): number
  • Return the number of instances of the specified object living on the scene.

    Parameters

    • objectName: string

      The object name for which instances must be counted.

    Returns number

  • getLayer(name: string): Layer
  • getName(): string
  • Get all the instances of the object called name.

    Parameters

    • name: string

      Name of the object for which the instances must be returned.

    Returns RuntimeObject[]

    The list of objects with the given name

  • getRequestedScene(): string
  • hasLayer(name: string): boolean
  • isObjectRegistered(objectName: string): boolean
  • Check if an object is registered, meaning that instances of it can be created and lives in the scene.

    see

    gdjs.RuntimeScene#registerObject

    Parameters

    • objectName: string

    Returns boolean

  • loadFromScene(sceneData: null | LayoutData): void
  • Load the runtime scene from the given scene.

    see

    gdjs.RuntimeGame#getSceneData

    Parameters

    • sceneData: null | LayoutData

      An object containing the scene data.

    Returns void

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

    Returns void

  • onPause(): 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

  • onResume(): void
  • registerObject(objectData: ObjectData): void
  • removeLayer(layerName: string): void
  • render(): void
  • renderAndStep(elapsedTime: number): boolean
  • Step and render the scene.

    Parameters

    • elapsedTime: number

    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

  • sceneJustResumed(): boolean
  • 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

  • setBackgroundColor(r: number, g: number, b: number): void
  • 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

  • setEventsFunction(func: () => void): 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

  • setEventsGeneratedCodeFunction(sceneData: LayoutData): 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

  • setInitialSharedDataForBehavior(name: string, sharedData: null | BehaviorSharedData): void
  • Set the data representing the initial shared data of the scene for the specified behavior.

    Parameters

    • name: string

      The name of the behavior

    • sharedData: null | BehaviorSharedData

      The shared data for the behavior, or null to remove it.

    Returns void

  • setLayerIndex(layerName: string, index: number): void
  • Change the position of a layer.

    Parameters

    • layerName: string

      The name of the layer to reorder

    • index: number

      The new position in the list of layers

    Returns void

  • startProfiler(onProfilerStopped: (oldProfiler: Profiler) => void): void
  • Start a new profiler to measures the time passed in sections of the engine in the scene.

    Parameters

    • onProfilerStopped: (oldProfiler: Profiler) => void

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

    Returns void

  • stopProfiler(): void
  • unloadScene(): void
  • unregisterObject(objectName: string): void
  • updateObject(objectData: ObjectData): void
  • updateObjectsForces(): void

Constructors

Properties

shiftyJsScene: Scene

Generated using TypeDoc