Options
All
  • Public
  • Public/Protected
  • All
Menu

Base class for 3D objects.

Hierarchy

Index

Methods

Properties

Constructors

Methods

  • activateBehavior(name: string, enable: boolean): void
  • De/activate a behavior of the object.

    Parameters

    • name: string

      The behavior name.

    • enable: boolean

      true to activate the behavior

    Returns void

  • addEffect(effectData: EffectData): boolean
  • Add a new effect, or replace the one with the same name.

    Parameters

    • effectData: EffectData

      The data describing the effect to add.

    Returns boolean

  • addForce(x: number, y: number, multiplier: number): void
  • Add a force to the object to move it.

    Parameters

    • x: number

      The x coordinates of the force

    • y: number

      The y coordinates of the force

    • multiplier: number

      Set the force multiplier

    Returns void

  • addForceTowardObject(object: RuntimeObject, len: number, multiplier: number): void
  • Add a force oriented toward another object.
    (Shortcut for addForceTowardPosition)

    Parameters

    • object: RuntimeObject

      The target object

    • len: number

      The force length, in pixels.

    • multiplier: number

      Set the force multiplier

    Returns void

  • addForceTowardPosition(x: number, y: number, len: number, multiplier: number): void
  • Add a force oriented toward a position

    Parameters

    • x: number

      The target x position

    • y: number

      The target y position

    • len: number

      The force length, in pixels.

    • multiplier: number

      Set the force multiplier

    Returns void

  • addNewBehavior(behaviorData: BehaviorData): boolean
  • Create the behavior described by the given BehaviorData

    Parameters

    • behaviorData: BehaviorData

      The data to be used to construct the behavior.

    Returns boolean

    true if the behavior was properly created, false otherwise.

  • addPolarForce(angle: number, len: number, multiplier: number): void
  • Add a force using polar coordinates.

    Parameters

    • angle: number

      The angle of the force, in degrees.

    • len: number

      The length of the force, in pixels.

    • multiplier: number

      Set the force multiplier

    Returns void

  • averageForceAngleIs(angle: number, toleranceInDegrees: number): boolean
  • Return true if the average angle of the forces applied on the object is in a given range.

    Parameters

    • angle: number

      The angle to be tested.

    • toleranceInDegrees: number

      The length of the range :

    Returns boolean

    true if the difference between the average angle of the forces and the angle parameter is inferior to toleranceInDegrees parameter.

  • behaviorActivated(name: string): boolean
  • Check if a behavior is activated

    Parameters

    • name: string

      The behavior name.

    Returns boolean

    true if the behavior is activated.

  • clearEffects(): boolean
  • clearForces(): void
  • Return true if the hitboxes of two objects are overlapping

    static

    Parameters

    • obj1: RuntimeObject

      The first runtimeObject

    • obj2: RuntimeObject

      The second runtimeObject

    • ignoreTouchingEdges: boolean

      If true, then edges that are touching each other, without the hitbox polygons actually overlapping, won't be considered in collision.

    Returns boolean

    true if obj1 and obj2 are in collision

  • Remove an object from a scene.

    Do not change/redefine this method. Instead, redefine the onDestroyFromScene method.

    Parameters

    Returns void

  • enableEffect(name: string, enable: boolean): void
  • Enable or disable an effect.

    Parameters

    • name: string

      The name of the effect to enable or disable.

    • enable: boolean

      true to enable, false to disable

    Returns void

  • extraInitializationFromInitialInstance(initialInstanceData: InstanceData): void
  • 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.

    Parameters

    • initialInstanceData: InstanceData

    Returns void

  • flipX(enable: boolean): void
  • Parameters

    • enable: boolean

    Returns void

  • flipY(enable: boolean): void
  • Parameters

    • enable: boolean

    Returns void

  • flipZ(enable: boolean): void
  • Parameters

    • enable: boolean

    Returns void

  • get3DRendererObject(): Object3D<Event>
  • 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.

    Returns AABB

    The bounding box

  • getAABBBottom(): number
  • getAABBCenterX(): number
  • getAABBCenterY(): number
  • getAABBLeft(): number
  • getAABBRight(): number
  • getAABBTop(): number
  • getAngle(): number
  • Get the rotation of the object.

    Returns number

    The rotation of the object, in degrees.

  • getAngleToPosition(targetX: number, targetY: number): number
  • Get the angle, in degrees, from the object center to a position.

    Parameters

    • targetX: number

      Target X position

    • targetY: number

      Target Y position

    Returns number

  • 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.

    Parameters

    • name: string

      The behavior name.

    Returns null | RuntimeBehavior

    The behavior with the given name, or undefined.

  • getCenterX(): number
  • 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.

    Returns number

    the X position of the object center, relative to getDrawableX().

  • getCenterXInScene(): number
  • Return the X position of the object center, relative to the scene origin.

    Returns number

    the X position of the object center, relative to the scene origin.

  • getCenterY(): number
  • 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.

    Returns number

    the Y position of the object center, relative to getDrawableY().

  • getCenterYInScene(): number
  • Return the Y position of the object center, relative to the scene origin.

    Returns number

    the Y position of the object center, relative to the scene origin.

  • getDepth(): number
  • Get the object size on the Z axis (called "depth").

    Returns number

  • getDistanceToPosition(targetX: number, targetY: number): number
  • Get the distance, in pixels, between the center of this object and a position.

    Parameters

    • targetX: number

      Target X position

    • targetY: number

      Target Y position

    Returns number

  • getDrawableX(): number
  • 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.

    Returns number

    The X position of the rendered object.

  • getDrawableY(): number
  • 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.

    Returns number

    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.

    Parameters

    • Optional instanceContainer: RuntimeInstanceContainer

      The instance container the object belongs to (deprecated - can be omitted).

    Returns number

  • getHeight(): number
  • 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.

    Returns Polygon[]

    An array composed of polygon.

  • getHitBoxesAround(left: number, top: number, right: number, bottom: number): Iterable<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:

    Parameters

    • left: number

      bound of the area in scene coordinates

    • top: number

      bound of the area in scene coordinates

    • right: number

      bound of the area in scene coordinates

    • bottom: number

      bound of the area in scene coordinates

    Returns Iterable<Polygon>

    at least all the hit boxes that overlap a given area.

  • getLayer(): string
  • Get the layer of the object.

    Returns string

    The layer of the object

  • getName(): string
  • getNameId(): number
  • Get the name identifier of the object.

    Returns number

    The object's name identifier.

  • getNameIdentifier(name: string): number
  • 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.

    static

    Parameters

    • name: string

    Returns number

  • getRendererEffects(): Record<string, Filter>
  • getRendererObject(): null
  • getRotationX(): number
  • Get the object rotation on the X axis.

    This is an Euler angle. Objects use the ZYX order.

    Returns number

  • getRotationY(): number
  • Get the object rotation on the Y axis.

    This is an Euler angle. Objects use the ZYX order.

    Returns number

  • getScale(): number
  • Get the scale of the object (or the geometric average of X, Y and Z scale in case they are different).

    Returns number

    the scale of the object (or the geometric average of X, Y and Z scale in case they are different).

  • getScaleX(): number
  • Get the scale of the object on X axis.

    Returns number

    the scale of the object on X axis

  • getScaleY(): number
  • Get the scale of the object on Y axis.

    Returns number

    the scale of the object on Y axis

  • getScaleZ(): number
  • Get the scale of the object on Z axis.

    Returns number

    the scale of the object on Z axis

  • getSqDistanceToPosition(targetX: number, targetY: number): number
  • Get the squared distance, in pixels, between the center of this object and a position.

    Parameters

    • targetX: number

      Target X position

    • targetY: number

      Target Y position

    Returns number

  • getTimerElapsedTimeInSeconds(timerName: string): number
  • 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.

    Parameters

    • timerName: string

      The timer name.

    Returns number

    The timer elapsed time in seconds, 0 if the timer doesn't exist.

  • getTimerElapsedTimeInSecondsOrNaN(timerName: string): number
  • Get a timer elapsed time.

    This is used by conditions to return false when a timer doesn't exist, no matter the relational operator.

    Parameters

    • timerName: string

      The timer name.

    Returns number

    The timer elapsed time in seconds, NaN if the timer doesn't exist.

  • getUniqueId(): number
  • 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.

    Returns number

    The object identifier

  • getVariableChildCount(variable: Variable): number
  • getVariableNumber(variable: Variable): number
  • Get the value of a variable considered as a number. Equivalent of variable.getAsNumber()

    static

    Parameters

    • variable: Variable

      The variable to be accessed

    Returns number

    The value of the specified variable

  • getVariableString(variable: Variable): string
  • Get the value of a variable considered as a string. Equivalent of variable.getAsString()

    static

    Parameters

    • variable: Variable

      The variable to be accessed

    Returns string

    The string of the specified variable

  • getVisibilityAABB(): null | AABB
  • 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.

    Returns null | AABB

    The bounding box or null.

  • getWidth(): number
  • getX(): number
  • Get the X position of the object.

    Returns number

    The X position of the object

  • getXFromAngleAndDistance(angle: number, distance: number): number
  • 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.

    Parameters

    • angle: number

      The angle, in degrees.

    • distance: number

      The distance from the object, in pixels

    Returns number

  • getY(): number
  • Get the Y position of the object.

    Returns number

    The Y position of the object

  • getYFromAngleAndDistance(angle: number, distance: number): number
  • 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.

    Parameters

    • angle: number

      The angle, in degrees.

    • distance: number

      The distance from the object, in pixels

    Returns number

  • getZ(): number
  • Get the object position on the Z axis.

    Returns number

  • getZOrder(): number
  • Get the Z order of the object.

    Returns number

    The Z order of the object

  • hasBehavior(name: string): boolean
  • Check if a behavior is used by the object.

    Parameters

    • name: string

      The behavior name.

    Returns boolean

  • hasEffect(name: string): boolean
  • Check if an effect exists on this object

    Parameters

    • name: string

      The name of the effect

    Returns boolean

    true if the effect exists, false otherwise.

  • hasNoForces(): boolean
  • Return true if no forces are applied on the object.

    Returns boolean

    true if no forces are applied on the object.

  • hasVariable(name: string): boolean
  • Shortcut to test if a variable exists for the object.

    Parameters

    • name: string

      The variable to be tested

    Returns boolean

    true if the variable exists.

  • hide(enable: boolean): void
  • Hide (or show) the object.

    Parameters

    • enable: boolean

    Returns void

  • insideObject(x: number, y: number): boolean
  • 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.

    Parameters

    • x: number
    • y: number

    Returns boolean

  • invalidateHitboxes(): void
  • isCollidingWithPoint(pointX: number, pointY: number): boolean
  • Check if a point is inside the object collision hitboxes.

    Parameters

    • pointX: number

      The point x coordinate.

    • pointY: number

      The point y coordinate.

    Returns boolean

    true if the point is inside the object collision hitboxes.

  • isEffectEnabled(name: string): boolean
  • Check if an effect is enabled

    Parameters

    • name: string

      The name of the effect

    Returns boolean

    true if the effect is enabled, false otherwise.

  • isFlippedX(): boolean
  • Returns boolean

  • isFlippedY(): boolean
  • Returns boolean

  • isFlippedZ(): boolean
  • Returns boolean

  • isHidden(): boolean
  • Return true if the object is hidden.

    Returns boolean

    true if the object is hidden.

  • isIncludedInParentCollisionMask(): boolean
  • isOnLayer(layer: string): boolean
  • Return true if the object is on the specified layer

    Parameters

    • layer: string

      The layer to be tested.

    Returns boolean

    true if the object is on the specified layer

  • isVisible(): boolean
  • 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.

    Returns boolean

    true if the object is not hidden.

  • notifyBehaviorsObjectHotReloaded(): void
  • onCreated(): void
  • 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);).

    Returns void

  • 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);).

    Parameters

    Returns void

  • Called whenever the scene owning the object is paused. This should not impact objects, but some may need to inform their renderer.

    Parameters

    Returns void

  • 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.

    Parameters

    Returns void

  • pauseTimer(timerName: string): void
  • Pause a timer. If the timer doesn't exist it is created.

    Parameters

    • timerName: string

      The timer name.

    Returns void

  • putAround(x: number, y: number, distance: number, angleInDegrees: number): void
  • 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.

    Parameters

    • x: number

      The x position of the target

    • y: number

      The y position of the target

    • distance: number

      The distance between the object and the target, in pixels.

    • angleInDegrees: number

      The angle between the object and the target, in degrees.

    Returns void

  • putAroundObject(obj: RuntimeObject, distance: number, angleInDegrees: number): void
  • Put the object around another object, with a specific distance and angle. The distance and angle are computed between the centers of the objects.

    Parameters

    • obj: RuntimeObject

      The target object

    • distance: number

      The distance between the object and the target

    • angleInDegrees: number

      The angle between the object and the target, in degrees.

    Returns void

  • raycastTest(x: number, y: number, endX: number, endY: number, closest: boolean): RaycastTestResult
  • Parameters

    • x: number

      The raycast source X

    • y: number

      The raycast source Y

    • endX: number

      The raycast end position X

    • endY: number

      The raycast end position Y

    • closest: boolean

      Get the closest or farthest collision mask result?

    Returns RaycastTestResult

    A raycast result with the contact points and distances

  • registerDestroyCallback(callback: () => void): void
  • reinitialize(objectData: ObjectData): void
  • 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:

    • Set gdjs.YourRuntimeObject.supportsReinitialization = true; to declare support for recycling.
    • Implement reinitialize. It must call the reinitialize of gdjs.RuntimeObject, and call this.onCreated(); at the end of reinitialize.
    • It must reset the object as if it was newly constructed (be careful about your renderers and any global state).
    • The _runtimeScene, _nameId, name and type are guaranteed to stay the same and do not need to be set again.

    Parameters

    • objectData: ObjectData

    Returns void

  • removeBehavior(name: string): boolean
  • 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).

    Parameters

    • name: string

      The name of the behavior to remove.

    Returns boolean

    true if the behavior was properly removed, false otherwise.

  • removeEffect(effectName: string): boolean
  • Remove the effect with the specified name

    Parameters

    • effectName: string

      The name of the effect.

    Returns boolean

  • removeTimer(timerName: string): void
  • resetTimer(timerName: string): void
  • Reset a timer. If the timer doesn't exist it is created.

    Parameters

    • timerName: string

      The timer name.

    Returns void

  • Return the variable passed as argument without any change. Only for usage by events.

    static

    Parameters

    • variable: Variable

      The variable to be accessed

    Returns Variable

    The specified variable

  • Rotate the object at the given speed

    Parameters

    • speed: number

      The speed, in degrees per second.

    • Optional instanceContainer: RuntimeInstanceContainer

      The container the object belongs to (deprecated - can be omitted).

    Returns void

  • rotateTowardPosition(x: number, y: number, speed: number, scene: RuntimeScene): void
  • separateFromObjects(objects: RuntimeObject[], ignoreTouchingEdges: boolean): boolean
  • Separate the object from others objects, using their hitboxes.

    Parameters

    • objects: RuntimeObject[]

      Objects

    • ignoreTouchingEdges: boolean

      If true, then edges that are touching each other, without the hitbox polygons actually overlapping, won't be considered in collision.

    Returns boolean

    true if the object was moved

  • separateFromObjectsList(objectsLists: ObjectsLists, ignoreTouchingEdges: boolean): boolean
  • Separate the object from others objects, using their hitboxes.

    Parameters

    • objectsLists: ObjectsLists

      Tables of objects

    • ignoreTouchingEdges: boolean

      If true, then edges that are touching each other, without the hitbox polygons actually overlapping, won't be considered in collision.

    Returns boolean

    true if the object was moved

  • separateObjectsWithForces(objectsLists: ObjectsLists): void
  • separateObjectsWithoutForces(objectsLists: ObjectsLists): void
  • setAngle(angle: number): void
  • setCenterPositionInScene(x: number, y: number): void
  • Change the object center position in the scene.

    Parameters

    • x: number

      The new X position of the center in the scene.

    • y: number

      The new Y position of the center in the scene.

    Returns void

  • setCenterXInScene(x: number): void
  • Change the object center X position in the scene.

    Parameters

    • x: number

      The new X position of the center in the scene.

    Returns void

  • setCenterYInScene(y: number): void
  • setDepth(depth: number): void
  • Set the object size on the Z axis (called "depth").

    Parameters

    • depth: number

    Returns void

  • setEffectBooleanParameter(name: string, parameterName: string, value: boolean): boolean
  • Change an effect parameter value (for parameters that are booleans).

    Parameters

    • name: string

      The name of the effect to update.

    • parameterName: string

      The name of the parameter to update.

    • value: boolean

      The new value (boolean).

    Returns boolean

  • setEffectDoubleParameter(name: string, parameterName: string, value: number): boolean
  • Change an effect parameter value (for parameters that are numbers).

    Parameters

    • name: string

      The name of the effect to update.

    • parameterName: string

      The name of the parameter to update.

    • value: number

      The new value (number).

    Returns boolean

  • setEffectStringParameter(name: string, parameterName: string, value: string): boolean
  • Change an effect parameter value (for parameters that are strings).

    Parameters

    • name: string

      The name of the effect to update.

    • parameterName: string

      The name of the parameter to update.

    • value: string

      The new value (string).

    Returns boolean

  • setHeight(height: number): void
  • Set the height of the object, if applicable.

    Parameters

    • height: number

    Returns void

  • setIncludedInParentCollisionMask(isIncluded: boolean): void
  • setLayer(layer: string): void
  • Set the layer of the object.

    Parameters

    • layer: string

      The new layer of the object

    Returns void

  • setPosition(x: number, y: number): void
  • Set the position of the object.

    Parameters

    • x: number

      The new X position

    • y: number

      The new Y position

    Returns void

  • setRotationX(angle: number): void
  • Set the object rotation on the X axis.

    This is an Euler angle. Objects use the ZYX order.

    Parameters

    • angle: number

    Returns void

  • setRotationY(angle: number): void
  • Set the object rotation on the Y axis.

    This is an Euler angle. Objects use the ZYX order.

    Parameters

    • angle: number

    Returns void

  • setScale(newScale: number): void
  • Change the scale on X, Y and Z axis of the object.

    Parameters

    • newScale: number

      The new scale (must be greater than 0).

    Returns void

  • setScaleX(newScale: number): void
  • Change the scale on X axis of the object (changing its width).

    Parameters

    • newScale: number

      The new scale (must be greater than 0).

    Returns void

  • setScaleY(newScale: number): void
  • Change the scale on Y axis of the object (changing its height).

    Parameters

    • newScale: number

      The new scale (must be greater than 0).

    Returns void

  • setScaleZ(newScale: number): void
  • Change the scale on Z axis of the object (changing its height).

    Parameters

    • newScale: number

      The new scale (must be greater than 0).

    Returns void

  • setVariableNumber(variable: Variable, newValue: number): void
  • Shortcut to set the value of a variable considered as a number

    Parameters

    • variable: Variable

      The variable to be changed

    • newValue: number

      The value to be set

    Returns void

  • setVariableString(variable: Variable, newValue: string): void
  • Shortcut to set the value of a variable considered as a string

    Parameters

    • variable: Variable

      The variable to be changed

    • newValue: string

      The value to be set

    Returns void

  • setWidth(width: number): void
  • Set the width of the object, if applicable.

    Parameters

    • width: number

    Returns void

  • setX(x: number): void
  • Set the X position of the object.

    Parameters

    • x: number

    Returns void

  • setY(y: number): void
  • Set the Y position of the object.

    Parameters

    • y: number

    Returns void

  • setZ(z: number): void
  • Set the object position on the Z axis.

    Parameters

    • z: number

    Returns void

  • setZOrder(z: number): void
  • Set the Z order of the object.

    Parameters

    • z: number

      The new Z order position of the object

    Returns void

  • timerElapsedTime(timerName: string, timeInSeconds: number): boolean
  • Compare a timer elapsed time. If the timer does not exist, it is created.

    deprecated

    prefer using getTimerElapsedTimeInSecondsOrNaN.

    Parameters

    • timerName: string

      The timer name.

    • timeInSeconds: number

      The time value to check in seconds.

    Returns boolean

    True if the timer exists and its value is greater than or equal than the given time, false otherwise.

  • timerPaused(timerName: string): boolean
  • Test a if a timer is paused.

    Parameters

    • timerName: string

      The timer name.

    Returns boolean

    True if the timer exists and is paused, false otherwise.

  • turnAroundX(deltaAngle: number): void
  • Turn the object around the scene x axis at its center.

    Parameters

    • deltaAngle: number

      the rotation angle

    Returns void

  • turnAroundY(deltaAngle: number): void
  • Turn the object around the scene y axis at its center.

    Parameters

    • deltaAngle: number

      the rotation angle

    Returns void

  • turnAroundZ(deltaAngle: number): void
  • Turn the object around the scene z axis at its center.

    Parameters

    • deltaAngle: number

      the rotation angle

    Returns void

  • unpauseTimer(timerName: string): void
  • Unpause a timer. If the timer doesn't exist it is created.

    Parameters

    • timerName: string

      The timer name.

    Returns void

  • unregisterDestroyCallback(callback: () => void): void
  • updateAABB(): void
  • 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.

    Returns void

  • updateAllEffectParameters(effectData: EffectData): boolean
  • updateForces(elapsedTime: number): void
  • Called once a step by runtimeScene to update forces magnitudes and remove null ones.

    Parameters

    • elapsedTime: number

    Returns void

  • 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.

    Parameters

    Returns boolean

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

  • updateHitBoxes(): void
  • 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.

    Returns void

  • updateTimers(elapsedTime: number): void
  • Updates the object timers. Called once during the game loop, before events and rendering.

    Parameters

    • elapsedTime: number

      The elapsed time since the previous frame in milliseconds.

    Returns void

Properties

angle: number = 0
forcesGarbage: Force[] = []

Global container for unused forces, avoiding recreating forces each tick.

static
getFirstVariableNumber: (array: Variable) => number = ...

Type declaration

    • Shortcut to get the first value of an array variable as a number.

      Parameters

      Returns number

getFirstVariableNumber: (array: Variable) => number = RuntimeObject.getFirstVariableNumber

Type declaration

    • Shortcut to get the first value of an array variable as a number.

      Parameters

      Returns number

getFirstVariableString: (array: Variable) => string = ...

Type declaration

    • Shortcut to get the first value of an array variable as a string.

      Parameters

      Returns string

getFirstVariableString: (array: Variable) => string = RuntimeObject.getFirstVariableString

Type declaration

    • Shortcut to get the first value of an array variable as a string.

      Parameters

      Returns string

getLastVariableNumber: (array: Variable) => number = ...

Type declaration

    • Shortcut to get the last value of an array variable as a number.

      Parameters

      Returns number

getLastVariableNumber: (array: Variable) => number = RuntimeObject.getLastVariableNumber

Type declaration

    • Shortcut to get the last value of an array variable as a number.

      Parameters

      Returns number

getLastVariableString: (array: Variable) => string = ...

Type declaration

    • Shortcut to get the last value of an array variable as a string.

      Parameters

      Returns string

getLastVariableString: (array: Variable) => string = RuntimeObject.getLastVariableString

Type declaration

    • Shortcut to get the last value of an array variable as a string.

      Parameters

      Returns string

getSqDistanceTo: (targetX: number, targetY: number) => number = RuntimeObject.prototype.getSqDistanceToPosition

Type declaration

    • (targetX: number, targetY: number): number
    • Get the squared distance, in pixels, between the center of this object and a position.

      Parameters

      • targetX: number

        Target X position

      • targetY: number

        Target Y position

      Returns number

getVariableBoolean: (variable: Variable, compareWith: boolean) => boolean = RuntimeObject.getVariableBoolean

Type declaration

    • (variable: Variable, compareWith: boolean): boolean
    • Shortcut to compare the value of a variable considered as a boolean. This shortcut function is needed for events code generation.

      Parameters

      Returns boolean

getVariableChildCount: (variable: Variable) => number = RuntimeObject.getVariableChildCount

Type declaration

    • Get the number of children from a variable

      static

      Parameters

      • variable: Variable

        The variable to be accessed

      Returns number

      The number of children

getVariableNumber: (variable: Variable) => number = RuntimeObject.getVariableNumber

Type declaration

    • Get the value of a variable considered as a number. Equivalent of variable.getAsNumber()

      static

      Parameters

      • variable: Variable

        The variable to be accessed

      Returns number

      The value of the specified variable

getVariableString: (variable: Variable) => string = RuntimeObject.getVariableString

Type declaration

    • Get the value of a variable considered as a string. Equivalent of variable.getAsString()

      static

      Parameters

      • variable: Variable

        The variable to be accessed

      Returns string

      The string of the specified variable

hidden: boolean = false
id: number
layer: string = ''
name: string
persistentUuid: null | string = null

An optional UUID associated to the object to be used for hot reload. Don't modify or use otherwise.

pick: boolean = false

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.

returnVariable: (variable: Variable) => Variable = RuntimeObject.returnVariable

Type declaration

    • Return the variable passed as argument without any change. Only for usage by events.

      static

      Parameters

      • variable: Variable

        The variable to be accessed

      Returns Variable

      The specified variable

setVariableBoolean: (variable: Variable, newValue: boolean) => void = RuntimeObject.setVariableBoolean

Type declaration

    • (variable: Variable, newValue: boolean): void
    • Shortcut to set the value of a variable considered as a boolean. This shortcut function is needed for events code generation.

      Parameters

      Returns void

setVariableNumber: (variable: Variable, newValue: number) => void = RuntimeObject.setVariableNumber

Type declaration

    • (variable: Variable, newValue: number): void
    • Shortcut to set the value of a variable considered as a number

      Parameters

      • variable: Variable

        The variable to be changed

      • newValue: number

        The value to be set

      Returns void

setVariableString: (variable: Variable, newValue: string) => void = RuntimeObject.setVariableString

Type declaration

    • (variable: Variable, newValue: string): void
    • Shortcut to set the value of a variable considered as a string

      Parameters

      • variable: Variable

        The variable to be changed

      • newValue: string

        The value to be set

      Returns void

supportsReinitialization: boolean = false
toggleVariableBoolean: (variable: Variable) => void = RuntimeObject.toggleVariableBoolean

Type declaration

    • Toggles a variable. This shortcut function is needed for events code generation.

      see

      {gdjs.evtTools.common.toggleVariableBoolean}

      Parameters

      Returns void

type: string
valuePush: (array: Variable, value: string | number | boolean) => void = RuntimeObject.valuePush

Type declaration

    • (array: Variable, value: string | number | boolean): void
    • This shortcut function is needed for events code generation.

      Parameters

      • array: Variable
      • value: string | number | boolean

      Returns void

variableChildExists: (variable: Variable, childName: string) => boolean = RuntimeObject.variableChildExists

Type declaration

    • (variable: Variable, childName: string): boolean
    • static

      Parameters

      • variable: Variable

        The variable to be tested

      • childName: string

        The name of the child

      Returns boolean

variableClearChildren: (variable: Variable) => void = RuntimeObject.variableClearChildren

Type declaration

    • static

      Parameters

      • variable: Variable

        The variable to be cleared

      Returns void

variablePushCopy: (array: Variable, variable: Variable) => void = RuntimeObject.variablePushCopy

Type declaration

    • This shortcut function is needed for events code generation.

      Parameters

      Returns void

variableRemoveAt: (array: Variable, index: number) => void = RuntimeObject.variableRemoveAt

Type declaration

    • This shortcut function is needed for events code generation.

      Parameters

      Returns void

variableRemoveChild: (variable: Variable, childName: string) => void = RuntimeObject.variableRemoveChild

Type declaration

    • (variable: Variable, childName: string): void
    • static

      Parameters

      • variable: Variable

        The variable to be changed

      • childName: string

        The name of the child

      Returns void

x: number = 0
y: number = 0
zOrder: number = 0
aabb: AABB = ...
hitBoxes: Polygon[]
hitBoxesDirty: boolean = true
getVariableBoolean: (variable: Variable, compareWith: boolean) => boolean = ...

Type declaration

    • (variable: Variable, compareWith: boolean): boolean
    • Shortcut to compare the value of a variable considered as a boolean. This shortcut function is needed for events code generation.

      Parameters

      Returns boolean

setVariableBoolean: (variable: Variable, newValue: boolean) => void = ...

Type declaration

    • (variable: Variable, newValue: boolean): void
    • Shortcut to set the value of a variable considered as a boolean. This shortcut function is needed for events code generation.

      Parameters

      Returns void

toggleVariableBoolean: (variable: Variable) => void = ...

Type declaration

    • Toggles a variable. This shortcut function is needed for events code generation.

      see

      {gdjs.evtTools.common.toggleVariableBoolean}

      Parameters

      Returns void

valuePush: (array: Variable, value: string | number | boolean) => void = ...

Type declaration

    • (array: Variable, value: string | number | boolean): void
    • This shortcut function is needed for events code generation.

      Parameters

      • array: Variable
      • value: string | number | boolean

      Returns void

variablePushCopy: (array: Variable, variable: Variable) => void = ...

Type declaration

    • This shortcut function is needed for events code generation.

      Parameters

      Returns void

variableRemoveAt: (array: Variable, index: number) => void = ...

Type declaration

    • This shortcut function is needed for events code generation.

      Parameters

      Returns void

Constructors

Generated using TypeDoc