De/activate a behavior of the object.
The behavior name.
true to activate the behavior
Add a new effect, or replace the one with the same name.
The data describing the effect to add.
Add a force to the object to move it.
The x coordinates of the force
The y coordinates of the force
Set the force multiplier
Add a force oriented toward another object.
(Shortcut for addForceTowardPosition)
The target object
The force length, in pixels.
Set the force multiplier
Add a force oriented toward a position
The target x position
The target y position
The force length, in pixels.
Set the force multiplier
Create the behavior described by the given BehaviorData
The data to be used to construct the behavior.
true if the behavior was properly created, false otherwise.
Add a force using polar coordinates.
The angle of the force, in degrees.
The length of the force, in pixels.
Set the force multiplier
Return an array containing the coordinates of the point passed as parameter in object local coordinates (as opposed to the parent coordinate coordinates).
All transformations (flipping, scale, rotation) are supported.
The X position of the point, in parent coordinates.
The Y position of the point, in parent coordinates.
Return an array containing the coordinates of the point passed as parameter in parent coordinate coordinates (as opposed to the object local coordinates).
All transformations (flipping, scale, rotation) are supported.
The X position of the point, in object coordinates.
The Y position of the point, in object coordinates.
Return true if the average angle of the forces applied on the object is in a given range.
The angle to be tested.
The length of the range :
true if the difference between the average angle of the forces and the angle parameter is inferior to toleranceInDegrees parameter.
Check if a behavior is activated
The behavior name.
true if the behavior is activated.
Remove all effects.
Deletes all forces applied on the object
Return true if the hitboxes of two objects are overlapping
The first runtimeObject
The second runtimeObject
If true, then edges that are touching each other, without the hitbox polygons actually overlapping, won't be considered in collision.
A polygon from the obj1
collision mask to ignore
true if obj1 and obj2 are in collision
Return true if the cursor, or any touch, is on the object.
true if the cursor, or any touch, is on the object.
Remove an object from a scene.
Do not change/redefine this method. Instead, redefine the onDestroyFromScene method.
The container owning the object.
Check the distance between two objects.
This method is called each tick after events are done.
The instanceContainer owning the object
Enable or disable an effect.
The name of the effect to enable or disable.
true to enable, false to disable
Called when the object is created from an initial instance at the startup of the scene.
Note that common properties (position, angle, z order...) have already been setup.
The internal object for a 3D rendering (PIXI.DisplayObject...)
Get the AABB (axis aligned bounding box) for the object.
The default implementation uses either the position/size of the object (when angle is 0) or hitboxes (when angle is not 0) to compute the bounding box. Result is cached until invalidated (by a position change, angle change...).
You should probably redefine updateAABB instead of this function.
The bounding box
Shortcut for getAABB().max[1]
.
See getAABB.
Shortcut for getting the center on the X coordinates of the object AABB. See getAABB.
Shortcut for getting the center on the Y coordinates of the object AABB. See getAABB.
Shortcut for getAABB().min[0]
.
See getAABB.
Shortcut for getAABB().max[0]
.
See getAABB.
Shortcut for getAABB().min[1]
.
See getAABB.
Get the rotation of the object.
The rotation of the object, in degrees.
Get the angle, in degrees, from the object center to another object.
The other object
Get the angle, in degrees, from the object center to a position.
Target X position
Target Y position
Return the sprite animator.
It returns null
when custom objects don't have the Animatable capability.
Return a force which is the sum of all forces applied on the object.
A force object.
Get a behavior from its name.
If the behavior does not exists, undefined
is returned.
Never keep a reference to a behavior, as they can be hot-reloaded. Instead, always call getBehavior on the object.
The behavior name.
The behavior with the given name, or undefined.
Return the X position of the object center, relative to the object X position (getDrawableX
).
Use getCenterXInScene
to get the position of the center in the scene.
the X position of the object center, relative to getDrawableX()
.
Return the X position of the object center, relative to the scene origin.
the X position of the object center, relative to the scene origin.
Return the Y position of the object center, relative to the object position (getDrawableY
).
Use getCenterYInScene
to get the position of the center in the scene.
the Y position of the object center, relative to getDrawableY()
.
Return the Y position of the object center, relative to the scene origin.
the Y position of the object center, relative to the scene origin.
Get the distance, in pixels, between the center of this object and another object.
The other object
Get the distance, in pixels, between the center of this object and a position.
Target X position
Target Y position
Get the X position of the rendered object.
For most objects, this will returns the same value as getX(). But if the object has an origin that is not the same as the point (0,0) of the object displayed, getDrawableX will differ.
The X position of the rendered object.
Get the Y position of the rendered object.
For most objects, this will returns the same value as getY(). But if the object has an origin that is not the same as the point (0,0) of the object displayed, getDrawableY will differ.
The Y position of the rendered object.
Return the time elapsed since the last frame, in milliseconds, for the object.
Objects can have different elapsed time if they are on layers with different time scales.
The instance container the object belongs to (deprecated - can be omitted).
Return the width of the object.
The height of the object
Get all the hit boxes for the object.
For collision checks, getHitBoxesAround should be used instead.
The default implementation returns a basic bounding box based the size (getWidth and getHeight) and the center point of the object (getCenterX and getCenterY).
You should probably redefine updateHitBoxes instead of this function.
An array composed of polygon.
Return at least all the hit boxes that overlap a given area.
The hit boxes don't need to actually overlap the area, (i.e: it's correct to return more hit boxes than those in the specified area) but the ones that do must be returned.
The default implementation returns the same as getHitBoxes.
This method can be overridden by grid based objects (or other objects that can quickly compute which hitboxes are touching a given area) to optimize collision checks.
When overriding this method, the following ones should be overridden too:
bound of the area in scene coordinates
bound of the area in scene coordinates
bound of the area in scene coordinates
bound of the area in scene coordinates
at least all the hit boxes that overlap a given area.
the internal right bound of the object according to its children.
the internal bottom bound of the object according to its children.
the internal left bound of the object according to its children.
the internal top bound of the object according to its children.
The container the object belongs to.
Get the layer of the object.
The layer of the object
Return the affine transformation that represents flipping, scale, rotation and translation of the object.
the affine transformation.
Get the name of the object.
The object's name.
Get the name identifier of the object.
The object's name identifier.
Get the identifier associated to an object name. Some features may want to compare objects name a large number of time. In this case, it may be more efficient to compare objects name identifiers.
Called when trying to send all information about the state of an object to other peers. This can be redefined by objects to send more information.
The full network sync data.
Get the transparency of the object.
The opacity, between 0 (transparent) and 255 (opaque).
The gdjs.RuntimeScene the object belongs to.
Returns the collection of effects to be rendered by the underlying renderer.
The renderer effects.
The internal object for a 2D rendering (PIXI.DisplayObject...)
The gdjs.RuntimeScene the object belongs to.
Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).
the scale of the object (or the geometric mean of the X and Y scale in case they are different).
Get the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).
the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).
Get the scale of the object on X axis.
the scale of the object on X axis
Get the scale of the object on Y axis.
the scale of the object on Y axis
Get the squared distance, in pixels, between the center of this object and another object.
The other object
Get the squared distance, in pixels, between the center of this object and a position.
Target X position
Target Y position
Get a timer elapsed time.
This is used by expressions to return 0 when a timer doesn't exist because numeric expressions must always return a number.
The timer name.
The timer elapsed time in seconds, 0 if the timer doesn't exist.
Get a timer elapsed time.
This is used by conditions to return false when a timer doesn't exist, no matter the relational operator.
The timer name.
The timer elapsed time in seconds, NaN if the timer doesn't exist.
Get the unique identifier of the object.
The identifier is set by the runtimeScene owning the object.
You can also use the id property (this._object.id) for increased efficiency instead of
calling this method.
The object identifier
the center X from the local origin (0;0).
the center Y from the local origin (0;0).
the internal height of the object according to its children.
the internal width of the object according to its children.
Get the number of children from a variable
The variable to be accessed
The number of children
Get the value of a variable considered as a number. Equivalent of variable.getAsNumber()
The variable to be accessed
The value of the specified variable
Get the value of a variable considered as a string. Equivalent of variable.getAsString()
The variable to be accessed
The string of the specified variable
Get the container of the object variables
The variables of the object
Get the AABB (axis aligned bounding box) to be used to determine if the object is visible on screen. The gdjs.RuntimeScene will hide the renderer object if the object is not visible on screen ("culling").
The default implementation uses the AABB returned by getAABB.
If null
is returned, the object is assumed to be always visible.
The bounding box or null
.
Return the width of the object.
The width of the object
Get the X position of the object.
The X position of the object
Compute the X position when given an angle and distance relative to the starting object. This is also known as getting the cartesian coordinates of a 2D vector, using its polar coordinates.
The angle, in degrees.
The distance from the object, in pixels
Get the Y position of the object.
The Y position of the object
Compute the Y position when given an angle and distance relative to the starting object. This is also known as getting the cartesian coordinates of a 2D vector, using its polar coordinates.
The angle, in degrees.
The distance from the object, in pixels
Get the Z order of the object.
The Z order of the object
Check if a behavior is used by the object.
The behavior name.
Check if an effect exists on this object
The name of the effect
true if the effect exists, false otherwise.
Return true if no forces are applied on the object.
true if no forces are applied on the object.
Shortcut to test if a variable exists for the object.
The variable to be tested
true if the variable exists.
Hide (or show) the object
true to hide the object, false to show it again.
Return true if the specified position is inside object bounding box.
The position should be in "world" coordinates, i.e use gdjs.Layer.convertCoords
if you need to pass the mouse or a touch position that you get from gdjs.InputManager.
To check if a point is inside the object collision mask, you can use isCollidingWithPoint
instead.
Send a signal that the object hitboxes are no longer up to date.
The signal is propagated to parents so gdjs.RuntimeObject.hitBoxesDirty should never be modified directly.
Check if a point is inside the object collision hitboxes.
The point x coordinate.
The point y coordinate.
true if the point is inside the object collision hitboxes.
Check if an effect is enabled
The name of the effect
true if the effect is enabled, false otherwise.
Return true if the object is hidden.
true if the object is hidden.
Return true if the object is on the specified layer
The layer to be tested.
true if the object is on the specified layer
Return true if the angle of the total force applied on the object is in a given range.
The angle to be tested.
The maximum distance from the given angle.
true if the difference between the force angle the given angle
is less or equals the toleranceInDegrees
.
Return true if the object is not hidden.
Note: This is unrelated to the actual visibility of the object on the screen.
For this, see getVisibilityAABB
to get the bounding boxes of the object as displayed
on the scene.
true if the object is not hidden.
Called when the object was hot reloaded, to notify behaviors that the object was modified. Useful for behaviors that
To be called by the child classes in their constructor, at the very end. Notify the behaviors that they have been constructed (this must be done when the object is ready, otherwise behaviors can do operations on the object which could be not initialized yet).
If you redefine this function, make sure to call the original method
(RuntimeObject.prototype.onCreated.call(this);
).
Called when the object is destroyed (because it is removed from a scene or the scene
is being unloaded). If you redefine this function, make sure to call the original method
(RuntimeObject.prototype.onDestroyFromScene.call(this, runtimeScene);
).
This method is called when the object is being removed from its parent container and is about to be destroyed/reused later.
This method is called when the preview is being hot-reloaded.
Called whenever the scene owning the object is paused. This should not impact objects, but some may need to inform their renderer.
The scene owning the object.
Called whenever the scene owning the object is resumed after a pause. This should not impact objects, but some may need to inform their renderer.
The scene owning the object.
Pause a timer. If the timer doesn't exist it is created.
The timer name.
Put the object around a position, with a specific distance and angle. The distance and angle are computed between the position and the center of the object.
The x position of the target
The y position of the target
The distance between the object and the target, in pixels.
The angle between the object and the target, in degrees.
Put the object around another object, with a specific distance and angle. The distance and angle are computed between the centers of the objects.
The target object
The distance between the object and the target
The angle between the object and the target, in degrees.
The raycast source X
The raycast source Y
The raycast end position X
The raycast end position Y
Get the closest or farthest collision mask result?
A raycast result with the contact points and distances
Called to reset the object to its default state. This is used for objects that are
"recycled": they are dismissed (at which point onDestroyFromScene
is called) but still
stored in a cache to be reused next time an object must be created. At this point,
reinitialize
will be called. The object must then work as if it was a newly constructed
object.
To implement this in your object:
gdjs.YourRuntimeObject.supportsReinitialization = true;
to declare support for recycling.reinitialize
. It must call the reinitialize
of gdjs.RuntimeObject
, and call this.onCreated();
at the end of reinitialize
._runtimeScene
, _nameId
, name
and type
are guaranteed to stay the same and do not
need to be set again.Remove the behavior with the given name. Usually only used by hot-reloading, as performance of this operation is not guaranteed (in the future, this could lead to re-organization of arrays holding behaviors).
The name of the behavior to remove.
true if the behavior was properly removed, false otherwise.
Remove the effect with the specified name
The name of the effect.
Remove a timer
The timer name.
Reset a timer. If the timer doesn't exist it is created.
The timer name.
Rotate the object at the given speed
The speed, in degrees per second.
The container the object belongs to (deprecated - can be omitted).
The targeted direction angle.
The rotation speed.
The container the object belongs to (deprecated - can be omitted).
Separate the object from others objects, using their hitboxes.
Objects
If true, then edges that are touching each other, without the hitbox polygons actually overlapping, won't be considered in collision.
true if the object was moved
Separate the object from others objects, using their hitboxes.
Tables of objects
If true, then edges that are touching each other, without the hitbox polygons actually overlapping, won't be considered in collision.
true if the object was moved
Tables of objects
Tables of objects
Set the angle of the object.
Change the object center position in the scene.
The new X position of the center in the scene.
The new Y position of the center in the scene.
Change the object center X position in the scene.
The new X position of the center in the scene.
Change the object center Y position in the scene.
Change an effect property value (for properties that are booleans).
The name of the effect to update.
The name of the property to update.
The new value (boolean).
Change an effect property value (for properties that are numbers).
The name of the effect to update.
The name of the property to update.
The new value (number).
Change an effect property value (for properties that are strings).
The name of the effect to update.
The name of the property to update.
The new value (string).
Change the height of the object. This changes the scale on Y axis of the object.
Set the layer of the object.
The new layer of the object
Change the transparency of the object.
Set the position of the object.
The new X position
The new Y position
The center of rotation is defined relatively to the origin (the object position). This avoids the center to move when children push the bounds.
When no custom center is defined, it will move to stay at the center of the children bounds.
coordinate of the custom center
coordinate of the custom center
Change the scale on X and Y axis of the object.
The new scale (must be greater than 0).
Change the scale on X axis of the object (changing its width).
The new scale (must be greater than 0).
Change the scale on Y axis of the object (changing its height).
The new scale (must be greater than 0).
Change the size of the object.
The new width of the object, in pixels.
The new height of the object, in pixels.
Shortcut to set the value of a variable considered as a number
The variable to be changed
The value to be set
Shortcut to set the value of a variable considered as a string
The variable to be changed
The value to be set
Change the width of the object. This changes the scale on X axis of the object.
Set the X position of the object.
Set the Y position of the object.
Set the Z order of the object.
The new Z order position of the object
Call each behavior stepPostEvents method.
Call each behavior stepPreEvents method.
Compare a timer elapsed time. If the timer does not exist, it is created.
The timer name.
The time value to check in seconds.
True if the timer exists and its value is greater than or equal than the given time, false otherwise.
Test a if a timer is paused.
The timer name.
True if the timer exists and is paused, false otherwise.
Unpause a timer. If the timer doesn't exist it is created.
The timer name.
Called once during the game loop, before events and rendering.
Update the AABB (axis aligned bounding box) for the object.
Default implementation uses either the position/size of the object (when angle is 0) or hitboxes (when angle is not 0) to compute the bounding box.
You should not call this function by yourself, it is called when necessary by getAABB method. However, you can redefine it if your object can have a faster implementation.
Updates all the parameters of an effect.
The data describing the effect
Called once a step by runtimeScene to update forces magnitudes and remove null ones.
Called when the object must be updated using the specified networkSyncData. This is the case during an update of the object from the network.
The new data for the object.
true if the object was updated, false if it could not (i.e: network sync is not supported).
Called when the object must be updated using the specified objectData. This is the case during hot-reload, and is only called if the object was modified.
true if the object was updated, false if it could not (i.e: hot-reload is not supported).
Update the hit boxes for the object.
The default implementation set a basic bounding box based on the size (getWidth and getHeight) and the center point of the object (getCenterX and getCenterY). Result is cached until invalidated (by a position change, angle change...).
You should not call this function by yourself, it is called when necessary by getHitBoxes method. However, you can redefine it if your object need custom hit boxes.
Called once during the game loop, after events and before rendering.
Updates the object timers. Called once during the game loop, before events and rendering.
The elapsed time since the previous frame in milliseconds.
Global container for unused forces, avoiding recreating forces each tick.
Shortcut to get the first value of an array variable as a number.
Shortcut to get the first value of an array variable as a number.
Shortcut to get the first value of an array variable as a string.
Shortcut to get the first value of an array variable as a string.
Shortcut to get the last value of an array variable as a number.
Shortcut to get the last value of an array variable as a number.
Shortcut to get the last value of an array variable as a string.
Shortcut to get the last value of an array variable as a string.
Get the squared distance, in pixels, between the center of this object and a position.
Target X position
Target Y position
Shortcut to compare the value of a variable considered as a boolean. This shortcut function is needed for events code generation.
Get the number of children from a variable
The variable to be accessed
The number of children
Get the value of a variable considered as a number. Equivalent of variable.getAsNumber()
The variable to be accessed
The value of the specified variable
Get the value of a variable considered as a string. Equivalent of variable.getAsString()
The variable to be accessed
The string of the specified variable
A network ID associated to the object to be used for multiplayer, to identify the object across peers. We don't use persistentUuid as it's only used for hot-reload. We don't use the object ID either as it's not unique across peers.
An optional UUID associated to the object to be used for hot reload. Don't modify or use otherwise.
A property to be used by external algorithms to indicate if the object is picked or not in an object selection. By construction, this is not "thread safe" or "re-entrant algorithm" safe.
Shortcut to set the value of a variable considered as a boolean. This shortcut function is needed for events code generation.
Shortcut to set the value of a variable considered as a number
The variable to be changed
The value to be set
Shortcut to set the value of a variable considered as a string
The variable to be changed
The value to be set
Toggles a variable. This shortcut function is needed for events code generation.
This shortcut function is needed for events code generation.
The variable to be tested
The name of the child
The variable to be cleared
This shortcut function is needed for events code generation.
The variable to be changed
The name of the child
Shortcut to compare the value of a variable considered as a boolean. This shortcut function is needed for events code generation.
Shortcut to set the value of a variable considered as a boolean. This shortcut function is needed for events code generation.
Toggles a variable. This shortcut function is needed for events code generation.
This shortcut function is needed for events code generation.
This shortcut function is needed for events code generation.
The container the object belongs to
The object data used to initialize the object
Generated using TypeDoc
An object that contains other object.
This is the base class for objects generated from EventsBasedObject.
gdjs.CustomRuntimeObjectInstanceContainer