RuntimeBehavior

RuntimeBehavior

RuntimeBehavior represents a behavior being used by a RuntimeObject.

Constructor

new RuntimeBehavior(runtimeScene, behaviorData, owner)

Parameters:
Name Type Description
runtimeScene

The scene owning the object of the behavior

behaviorData

The properties used to setup the behavior

owner

The object owning the behavior

Source:

Methods

activate(enable)

De/Activate the behavior

Parameters:
Name Type Description
enable

true to enable the behavior, false to disable it

Source:

activated()

Return true if the behavior is activated

Source:

doStepPostEvents(runtimeScene)

This method is called each tick after events are done.

Parameters:
Name Type Description
runtimeScene

The runtimeScene owning the object

Source:

doStepPreEvents(runtimeScene)

This method is called each tick before events are done.

Parameters:
Name Type Description
runtimeScene

The runtimeScene owning the object

Source:

getName()

Get the name of the behavior.

Returns:
Type Description

The behavior's name.

Source:

getNameId()

Get the name identifier of the behavior.

Returns:
Type Description

The behavior's name identifier.

Source:

onActivate()

Reimplement this method to do extra work when the behavior is activated (after it has been deactivated, see onDeActivate).

Source:

onCreated()

Reimplement this to do extra work when the behavior is created (i.e: an object using it was created), after the object is fully initialized (so you can use this.owner without risk).

Source:

onDeActivate()

Reimplement this method to do extra work when the behavior is deactivated.

Source:

onDestroy()

This method is called when the owner of the behavior is being removed from the scene and is about to be destroyed/reused later or when the behavior is removed from an object (can happen in case of hot-reloading only. Otherwise, behaviors are just de-activated, not removed. See onDeActivate).

Source:

onObjectHotReloaded()

This method is called when the owner of the behavior was hot reloaded, so its position, angle, size can have been changed outside of events.

Source:

stepPostEvents(runtimeScene)

Called at each frame after events. Call doStepPostEvents.
Behaviors writers: Please do not redefine this method. Redefine doStepPreEvents instead.

Parameters:
Name Type Description
runtimeScene

The runtimeScene owning the object

Source:

stepPreEvents(runtimeScene)

Called at each frame before events. Call doStepPreEvents.
Behaviors writers: Please do not redefine this method. Redefine doStepPreEvents instead.

Parameters:
Name Type Description
runtimeScene

The runtimeScene owning the object

Source:

updateFromBehaviorData(oldBehaviorData, newBehaviorData)

Called when the behavior must be updated using the specified behaviorData. This is the case during hot-reload, and is only called if the behavior was modified.

Parameters:
Name Type Description
oldBehaviorData

The previous data for the behavior.

newBehaviorData

The new data for the behavior.

Returns:
Type Description

true if the behavior was updated, false if it could not (i.e: hot-reload is not supported).

Source:
See:
  • gdjs.RuntimeBehavior#onObjectHotReloaded