RuntimeScene

RuntimeScene

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

Constructor

new RuntimeScene(runtimeGame)

Parameters:
Name Type Description
runtimeGame

The game associated to this scene.

Source:

Methods

addLayer(layerData)

Add a layer.

Parameters:
Name Type Description
layerData

The data to construct the layer

Source:

addObject(obj)

Add an object to the instances living on the scene.

Parameters:
Name Type Description
obj

The object to be added.

Source:

createNewUniqueId()

Create an identifier for a new object of the scene.

Source:

createObject(objectName)

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:
Name Type Description
objectName

The name of the object to be created

Returns:
Type Description

The created object

Source:

createObjectsFrom(data, xPos, yPos, trackByPersistentUuid)

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

Parameters:
Name Type Description
data

The instances data

xPos

The offset on X axis

yPos

The offset on Y axis

trackByPersistentUuid

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

Source:

getAdhocListOfAllInstances()

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:
Type Description

The list of all runtime objects on the scnee

Source:

getAllLayerNames(result)

Fill the array passed as argument with the names of all layers

Parameters:
Name Type Description
result

The array where to put the layer names

Source:

getBackgroundColor()

Get the background color, as an hexadecimal number.

Returns:
Type Description

The current background color.

Source:

getGame()

Get the runtimeGame associated to the RuntimeScene.

Source:

getInitialSharedDataForBehavior(name)

Get the data representing the initial shared data of the scene for the specified behavior.

Parameters:
Name Type Description
name

The name of the behavior

Returns:
Type Description

The shared data for the behavior, if any.

Source:

getLayer(name)

Get the layer with the given name

Parameters:
Name Type Description
name

The name of the layer

Returns:
Type Description

The layer, or the base layer if not found

Source:

getName()

Get the name of the scene.

Source:

getObjects(name)

Get all the instances of the object called name.

Parameters:
Name Type Description
name

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

Returns:
Type Description

The list of objects with the given name

Source:

getOnceTriggers()

Get the structure containing the triggers for "Trigger once" conditions.

Source:

getProfiler()

Get the profiler associated with the scene, or null if none.

Source:

getRenderer()

Get the renderer associated to the RuntimeScene.

Source:

getRequestedChange()

Return the value of the scene change that is requested.

Source:

getRequestedScene()

Return the name of the new scene to be launched.

See requestChange.

Source:

getSoundManager()

Shortcut to get the SoundManager of the game.

Returns:
Type Description

The gdjs.SoundManager of the game.

Source:

getTimeManager()

Get the TimeManager of the scene.

Returns:
Type Description

The gdjs.TimeManager of the scene.

Source:

getVariables()

Get the variables of the runtimeScene.

Returns:
Type Description

The container holding the variables of the scene.

Source:

hasLayer(name)

Check if a layer exists

Parameters:
Name Type Description
name

The name of the layer

Source:

isObjectRegistered()

Check if an object is registered, meaning that instances of it can be created and lives in the scene.

Source:
See:
  • gdjs.RuntimeScene#registerObject

loadFromScene(sceneData)

Load the runtime scene from the given scene.

Parameters:
Name Type Description
sceneData

An object containing the scene data.

Source:
See:
  • gdjs.RuntimeGame#getSceneData

markObjectForDeletion(obj)

Must be called whenever an object must be removed from the scene.

Parameters:
Name Type Description
obj

The object to be removed.

Source:

onPause()

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

Source:

onResume()

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

Source:

registerObject(objectData)

Register a gdjs.RuntimeObject so that instances of it can be used in the scene.

Parameters:
Name Type Description
objectData

The data for the object to register.

Source:

removeLayer(layerName)

Remove a layer. All gdjs.RuntimeObject on this layer will be moved back to the base layer.

Parameters:
Name Type Description
layerName

The name of the layer to remove

Source:

render()

Render the PIXI container associated to the runtimeScene.

Source:

renderAndStep()

Step and render the scene.

Returns:
Type Description

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

Source:

requestChange(change, sceneName)

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

Parameters:
Name Type Description
change

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

sceneName

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

Source:

sceneJustResumed()

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

Returns:
Type Description

true if the scene was just resumed

Source:

setBackgroundColor(r, g, b)

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

Parameters:
Name Type Description
r

The color red component (0-255).

g

The color green component (0-255).

b

The color blue component (0-255).

Source:

setEventsFunction(func)

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:
Name Type Description
func

The function to be called.

Source:

setEventsGeneratedCodeFunction(sceneData)

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:
Name Type Description
sceneData

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

Source:

setInitialSharedDataForBehavior(name, sharedData)

Set the data representing the initial shared data of the scene for the specified behavior.

Parameters:
Name Type Description
name

The name of the behavior

sharedData

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

Source:

setLayerIndex(layerName, index)

Change the position of a layer.

Parameters:
Name Type Description
layerName

The name of the layer to reorder

index

The new position in the list of layers

Source:

startProfiler(onProfilerStopped)

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

Parameters:
Name Type Description
onProfilerStopped

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

Source:

stopProfiler()

Stop the profiler being run on the scene.

Source:

unloadScene()

Called before a scene is removed from the stack of scenes rendered on the screen.

Source:

unregisterObject(objectName)

Unregister a gdjs.RuntimeObject. Instances will be destroyed.

Parameters:
Name Type Description
objectName

The name of the object to unregister.

Source:

updateObject(objectData)

Update the data of a gdjs.RuntimeObject so that instances use this when constructed.

Parameters:
Name Type Description
objectData

The data for the object to register.

Source:

updateObjectsForces()

Update the objects positions according to their forces

Source: