Options
All
  • Public
  • Public/Protected
  • All
Menu

Holds game objects updated and/or rendered in the game loop.

Basically, just an Entity with an update implementation.

Example

const pickups = new Container()

// Assuming there is a 'Pickup' type in your game.
mapData.pickupLocations.forEach(pos => {
pickups.push(new Pickup(pos))
})

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

Properties

alpha

alpha: number

The opacity of the entity (from 0 to 1)

children

children: Partial<Entity>[]

An array of child entities for recursive update/render.

dead

dead: boolean

Whether or not the entity is dead.

pos

pos: Vec

Position of the entity.

scale

scale: Vec

Scale of the entity.

visible

visible: boolean

Whether or not the entity is visible.

Accessors

hasChildren

  • get hasChildren(): boolean

Methods

add

  • add<T>(child: T): T
  • Add and return a child object.

    Type parameters

    • T

    Parameters

    • child: T

      Object to add to the container.

    Returns T

map

  • map(fn: (child: Partial<Entity>, index?: number) => void): any
  • Map a function across all children.

    Parameters

    • fn: (child: Partial<Entity>, index?: number) => void

      Function to call for each child.

        • (child: Partial<Entity>, index?: number): void
        • Parameters

          • child: Partial<Entity>
          • Optional index: number

          Returns void

    Returns any

remove

  • remove<T>(child: T): T
  • Remove and return a child object.

    Type parameters

    • T

    Parameters

    • child: T

      Object to remove from the container.

    Returns T

update

  • update(dt: number, t: number): void
  • Update each child in the container.

    Automatically removes any child object marked as dead.

    Parameters

    • dt: number

      Delta time since last update.

    • t: number

      Timestamp in seconds.

    Returns void