Static
forcesGlobal container for unused forces, avoiding recreating forces each tick.
Static
getShortcut 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.
Static
getShortcut 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.
Static
getShortcut 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.
Static
getShortcut 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, from the object center to a position.
Use getSqDistanceToPosition
instead.
Private
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
Readonly
idA 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.
Private
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
{String} The value to be set
Static
supportsPrivate
Toggles a variable. This shortcut function is needed for events code generation.
Private
This shortcut function is needed for events code generation.
The variable to be tested
The name of the child
The variable to be cleared
Private
This shortcut function is needed for events code generation.
The variable to be changed
The name of the child
Protected
aabbProtected
hitProtected
hitStatic
Private
getShortcut to compare the value of a variable considered as a boolean. This shortcut function is needed for events code generation.
Static
Private
setShortcut to set the value of a variable considered as a boolean. This shortcut function is needed for events code generation.
Static
Private
toggleToggles a variable. This shortcut function is needed for events code generation.
Static
Private
valueThis shortcut function is needed for events code generation.
Static
Private
variableThis shortcut function is needed for events code generation.
Static
Private
variableThis shortcut function is needed for events code generation.
Add a force oriented toward another object.
(Shortcut for addForceTowardPosition)
The target object
The force length, in pixels.
Set the force multiplier
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.
Use isTotalForceAngleAround instead.
Static
collisionReturn 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.
Static
distanceCheck the distance between two objects.
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 data of the initial instance.
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 angle, in degrees, from the object center to another object.
The other 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.
{String} The behavior name.
The behavior with the given name, or undefined.
Get the distance, in pixels, between the center of this object and another object.
The other 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.
Optional
instanceContainer: RuntimeInstanceContainerThe instance container the object belongs to (deprecated - can be omitted).
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 container the object belongs to.
Static
getCalled 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 light obstacles manager.
the light obstacles manager.
The gdjs.RuntimeScene the object belongs to.
The gdjs.RuntimeScene the object belongs to.
Get the squared distance, in pixels, between the center of this object and another object.
The other object
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.
Static
getGet the number of children from a variable
The variable to be accessed
The number of children
Static
getGet the value of a variable considered as a number. Equivalent of variable.getAsNumber()
The variable to be accessed
The value of the specified variable
Static
getGet 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
.
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
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
Static
hexReturn 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.
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
.
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);
).
The container owning the object.
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.
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.
Static
returnRotate the object at the given speed
The speed, in degrees per second.
Optional
instanceContainer: RuntimeInstanceContainerThe container the object belongs to (deprecated - can be omitted).
The targeted direction angle.
The rotation speed.
Optional
instanceContainer: RuntimeInstanceContainerThe 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
Static
setShortcut to set the value of a variable considered as a number
The variable to be changed
The value to be set
Static
setShortcut to set the value of a variable considered as a string
The variable to be changed
{String} The value to be set
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.
prefer using getTimerElapsedTimeInSecondsOrNaN
.
Called once during the game loop, before events and rendering.
The container the object belongs to.
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.
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.
The previous data for the object.
The new data for the object.
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.
Displays a Light object.