An Entity is the base type of anything that can have behavior in Excalibur, they are part of the built in entity component system

Entities can be strongly typed with the components they contain

const entity = new Entity<ComponentA | ComponentB>();
entity.components.a; // Type ComponentA
entity.components.b; // Type ComponentB

Hierarchy

Constructors

Properties

active: boolean = true

Whether this entity is active, if set to false it will be reclaimed

childrenAdded$: Observable<Entity> = ...
childrenRemoved$: Observable<Entity> = ...
componentAdded$: Observable<AddedComponent> = ...

Observable that keeps track of component add or remove changes on the entity

componentRemoved$: Observable<RemovedComponent> = ...
events: EventEmitter<EntityEvents> = ...

Listen to or emit events for an entity

id: number = ...

The unique identifier for the entity

Reference to the [[IsometricMap]] this tile is part of

scene: Scene<unknown> = null

The scene that the entity is in, if any

solid: boolean = false

Indicates whether this tile is solid

x: number

Integer tile x coordinate

y: number

Integer tile y coordinate

Accessors

  • get tags(): readonly string[]
  • Specifically get the tags on the entity from [[TagComponent]]

    Returns readonly string[]

Methods

  • Internal

    Initializes this entity, meant to be called by the Scene before first update not by users of Excalibur.

    It is not recommended that internal excalibur methods be overridden, do so at your own risk.

    Parameters

    Returns void

  • Internal

    It is not recommended that internal excalibur methods be overridden, do so at your own risk.

    Internal _preupdate handler for [[onPostUpdate]] lifecycle event

    Parameters

    Returns void

  • Internal

    It is not recommended that internal excalibur methods be overridden, do so at your own risk.

    Internal _preupdate handler for [[onPreUpdate]] lifecycle event

    Parameters

    Returns void

  • Adds a collider to the IsometricTile

    Note! the [[Tile.solid]] must be set to true for it to act as a "fixed" collider

    Parameters

    Returns void

  • Adds a copy of all the components from another template entity as a "prefab"

    Parameters

    • templateEntity: Entity

      Entity to use as a template

    • force: boolean = false

      Force component replacement if it already exists on the target entity

    Returns Entity

  • Kill the entity, means it will no longer be updated. Kills are deferred to the end of the update. If parented it will be removed from the parent when killed.

    Returns void

  • onInitialize is called before the first update of the entity. This method is meant to be overridden.

    Synonymous with the event handler .on('initialize', (evt) => {...})

    Parameters

    Returns void

  • Safe to override onPostUpdate lifecycle event handler. Synonymous with .on('postupdate', (evt) =>{...})

    onPostUpdate is called directly after an entity is updated.

    Parameters

    Returns void

  • Safe to override onPreUpdate lifecycle event handler. Synonymous with .on('preupdate', (evt) =>{...})

    onPreUpdate is called directly before an entity is updated.

    Parameters

    Returns void

  • Removes a component from the entity, by default removals are deferred to the end of entity update to avoid consistency issues

    Components can be force removed with the force flag, the removal is not deferred and happens immediately

    Type Parameters

    • ComponentOrType extends string | Component<string>

    Parameters

    • componentOrType: ComponentOrType
    • force: boolean = false

    Returns Entity