Components are containers for state in Excalibur, the are meant to convey capabilities that an Entity possesses

Implementations of Component must have a zero-arg constructor to support dependencies

class MyComponent extends ex.Component<'my'> {
public readonly type = 'my';
// zero arg support required if you want to use component dependencies
constructor(public optionalPos?: ex.Vector) {}
}

Hierarchy

Constructors

Properties

$colliderAdded: Util.Observable<Collider> = ...

Observable that notifies when a collider is added to the body

$colliderRemoved: Util.Observable<Collider> = ...

Observable that notifies when a collider is removed from the body

dependencies?: ComponentCtor<Component<string>>[]

Optionally list any component types this component depends on If the owner entity does not have these components, new components will be added to the entity

Only components with zero-arg constructors are supported as automatic component dependencies

events: EventDispatcher<any> = ...
optional?: ComponentCtor<Component<string>>[]
owner?: Entity = null

Current owning Entity, if any, of this component. Null if not added to any Entity

type: "ex.collider" = 'ex.collider'

Type of this component, must be a unique type among component types in you game.

Accessors

Methods

  • Sets up a box geometry based on the current bounds of the associated actor of this physics body.

    If no width/height are specified the body will attempt to use the associated actor's width/height.

    By default, the box is center is at (0, 0) which means it is centered around the actors anchor.

    Parameters

    • width: number
    • height: number
    • anchor: Vector = Vector.Half
    • center: Vector = Vector.Zero

    Returns PolygonCollider