Options
All
  • Public
  • Public/Protected
  • All
Menu

Displays a Light object.

Hierarchy

Index

Methods

Properties

Constructors

Methods

  • activateBehavior(name: string, enable: boolean): void
  • addEffect(effectData: EffectData): boolean
  • addForce(x: number, y: number, multiplier: number): void
  • addForceTowardObject(object: null | RuntimeObject, len: number, multiplier: number): void
  • addForceTowardPosition(x: number, y: number, len: number, multiplier: number): void
  • addNewBehavior(behaviorData: BehaviorData): boolean
  • addPolarForce(angle: number, len: number, multiplier: number): 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.

    deprecated

    Use isTotalForceAngleAround instead.

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

    • ignoredObject1Polygon: null | Polygon = null

      A polygon from the obj1 collision mask to ignore

    Returns boolean

    true if obj1 and obj2 are in collision

  • enableEffect(name: string, enable: boolean): void
  • extraInitializationFromInitialInstance(initialInstanceData: InstanceData): void
  • get3DRendererObject(): undefined | null | Object3D<Object3DEventMap>
  • 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
  • getAngleToPosition(targetX: number, targetY: number): 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
  • 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
  • getColor(): string
  • getDebugMode(): boolean
  • getDistanceToPosition(targetX: number, targetY: number): number
  • getDrawableX(): number
  • getDrawableY(): number
  • getHeight(): number
  • 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
  • getName(): string
  • getNameId(): number
  • 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

  • getRadius(): number
  • getRendererEffects(): Record<string, Filter>
  • getRendererObject(): null | Container<DisplayObject> | Mesh<MeshMaterial>
  • getSqDistanceToPosition(targetX: number, targetY: number): number
  • getTexture(): string
  • 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
  • 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
  • getVariableString(variable: Variable): string
  • 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
  • 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
  • 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

  • getZOrder(): number
  • hasBehavior(name: string): boolean
  • hasEffect(name: string): boolean
  • hasNoForces(): boolean
  • hasVariable(name: string): boolean
  • hexToRGBColor(hex: any): number[]
  • hide(enable: boolean): 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
  • isEffectEnabled(name: string): boolean
  • isHidden(): boolean
  • isIncludedInParentCollisionMask(): boolean
  • isOnLayer(layer: string): boolean
  • isTotalForceAngleAround(angle: number, toleranceInDegrees: number): boolean
  • Return true if the angle of the total force applied on the object is in a given range.

    Parameters

    • angle: number

      The angle to be tested.

    • toleranceInDegrees: number

      The maximum distance from the given angle.

    Returns boolean

    true if the difference between the force angle the given angle is less or equals the toleranceInDegrees.

  • 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

  • onDestroyed(): void
  • pauseTimer(timerName: string): 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: null | 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: null | 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
  • removeTimer(timerName: string): void
  • resetTimer(timerName: string): 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
  • setCenterXInScene(x: number): void
  • setCenterYInScene(y: number): void
  • setColor(color: string): void
  • setEffectBooleanParameter(name: string, parameterName: string, value: boolean): boolean
  • setEffectDoubleParameter(name: string, parameterName: string, value: number): boolean
  • setEffectStringParameter(name: string, parameterName: string, value: string): boolean
  • setHeight(height: number): void
  • setIncludedInParentCollisionMask(isIncluded: boolean): void
  • setLayer(layer: string): void
  • setPosition(x: number, y: number): void
  • setRadius(radius: number): void
  • setVariableNumber(variable: Variable, newValue: number): void
  • setVariableString(variable: Variable, newValue: string): void
  • setWidth(width: number): void
  • setX(x: number): void
  • setY(y: number): void
  • setZOrder(z: number): 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
  • unpauseTimer(timerName: string): 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
  • 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

  • updatePreRender(): void
  • updateTimers(elapsedTime: number): 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
networkId: null | string = null

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.

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