Class Component<TypeName>Abstract

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) {}
}

Type Parameters

  • TypeName extends string = string

Hierarchy

Constructors

  • Type Parameters

    • TypeName extends string = string

    Returns Component<TypeName>

Properties

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

optional?: ComponentCtor<Component<string>>[]
owner?: Entity = null

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

type: TypeName

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

Methods