Skip to content

Latest commit

 

History

History
58 lines (34 loc) · 2.06 KB

File metadata and controls

58 lines (34 loc) · 2.06 KB

Scene

A scene is a level, screen, or world that can be loaded at any point during runtime.

You can provide the Scene constructor's config object with a layers array, containing data for generating layers in the scene. Each scene will automatically populate a layer with label "system" if none of the layer configurations in the config.layers array use that label.


Constructor

new Scene(runtime, config);

Arguments

  • runtimeRuntime The main runtime object.
  • configObject The scene configuration object.
    • config.labelstring The Scene's label.
    • config.layersArray<Object> An optional array of configuration objects for each layer in the Scene.
    • config.layers[].labelstring The layer's label.
    • config.layers[].parallaxArray<number> Optional parallax data, where the format is [integer, integer]. ([1, 1] is 100% parallax, [0, 0] is 0% parallax)
    • config.layers[].gameObjectConstructorsArray<function> Optional callback functions that return GameObjects for this layer.
    • config.layers[].gameObjectConstructors[]function A callback function, passed this Scene as an argument, that return an instance of GameObject. This GameObject is automatically added to the constructed Layer.
    • config.onLoadfunction A callback (passed this Scene as an argument) that runs when the Scene has finished loading.
    • config.onTickfunction A callback (passed this Scene as an argument) that runs every frame that this Scene is loaded.

Properties

layerManager

This scene's LayerManager instance.

camera

This scene's Camera instance.


camera

Get the camera associated with this scene.

Returns

  • Camera The camera object for the scene.

Methods

static validateConfig(config)

Validates a scene configuration file and throws an error if it is invalid.

Arguments

  • configObject The config object to validate.