Class MovingObject

A GameObject with a 2D position.

Hierarchy

Constructors

Properties

#children: GameObject[] = []
#drawHandlers: Set<((delta: number) => void)> = ...
#inSceneTree: boolean = false
#preloadHandlers: Set<(() => void | Promise<void>)> = ...
#readyHandlers: Set<(() => void)> = ...
#updateHandlers: Set<((delta: number) => void)> = ...
id: number

The numerical ID of a GameObject.

moveEveryFrame: boolean

Whether or not the velocity is applied every update.

name: string

The name of a GameObject.

parent: null | GameObject = null

The parent of a GameObject in the scene tree. If the object has no parent or is not in the scene tree, this value is null

pos: Vector2

The 2D world position of the Object2D, relative to its parent.

velocity: Vector2 = ...

The change in postion when the MovingObject moves.

cache: Map<number, GameObject> = ...

A map of GameObjects and their ids.

nextFreeID: number = 0

The next id available for a GameObject

Accessors

  • set inSceneTree(value: true): void
  • Set to true when the GameObject is added.

    Parameters

    • value: true

    Returns void

  • get onCeil(): boolean
  • Whether or not the MovingObject's collider is touching another Collider above it.

    Returns boolean

  • get onFloor(): boolean
  • Whether or not the MovingObject's collider is touching another Collider below it.

    Returns boolean

  • get onWall(): boolean
  • Whether or not the MovingObject's collider is touching another Collider to the left or right of it.

    Returns boolean

Methods

  • Moves the MovingObject by its velocity scaled by delta

    Parameters

    • delta: number

    Returns void

  • Built-in functionality of the GameObject called on draw.

    When extending GameObject, super.objectDraw(delta) must be called when overriding this.

    Parameters

    • delta: number

    Returns void

  • Built-in functionality of the GameObject called on preload.

    When extending GameObject, super.objectPreload() must be called when overriding this.

    Returns Promise<void>

  • Built-in functionality of the GameObject called on ready.

    When extending GameObject, super.objectReady() must be called when overriding this.

    Returns void

  • Built-in functionality of the GameObject called on update.

    When extending GameObject, super.objectUpdate(delta) must be called when overriding this.

    Parameters

    • delta: number

    Returns void

  • Adds a function to be called on preload. If the object is added to the scene after the game loads, it will be called right before the object is added.

    Parameters

    • f: (() => void | Promise<void>)
        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns MovingObject

  • Adds a function to be called on ready. If the object is added to the scene after the game loads, it will be called right after the object is added.

    Parameters

    • f: (() => void)
        • (): void
        • Returns void

    Returns MovingObject

Generated using TypeDoc