Skip to main content

MotionComponent

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 {
  // zero arg support required if you want to use component dependencies
  constructor(public optionalPos?: ex.Vector) {}
}

Hierarchy

Index

Constructors

constructor

Properties

publicacc

acc: Vector = Vector.Zero

The acceleration of entity in pixels per second^2

publicangularVelocity

angularVelocity: number = 0

The angular velocity which is how quickly the entity is rotating in radians per second

optionalreadonlyinheriteddependencies

dependencies?: ComponentCtor<Component>[]

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

publicinertia

inertia: number = 1

Inertia can be thought of as the resistance to motion

publicintegration

integration: { onScreenOnly: boolean } = ...

Configure per-entity integration systems


Type declaration

  • onScreenOnly: boolean

    Integrate on screen only entities, defaults to false meaning all entities are integrated

publicmaxVel

maxVel: Vector = ...

The maximum component-wise velocity of an entity in pixels per second

inheritedowner

owner: Entity<any> | null = null

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

publicscaleFactor

scaleFactor: Vector = Vector.Zero

The scale rate of change in scale units per second

publictorque

torque: number = 0

The amount of torque applied to the entity, angular acceleration is torque * inertia

publicvel

vel: Vector = Vector.Zero

The velocity of an entity in pixels per second

Methods

inheritedclone

  • Clones any properties on this component, if that property value has a clone() method it will be called


    Returns Component

inheriteddeserialize

  • deserialize(data: Record<string, any>): void
  • Parameters

    • data: Record<string, any>

    Returns void

optionalinheritedonAdd

  • Optional callback called when a component is added to an entity


    Parameters

    Returns void

optionalinheritedonRemove

  • onRemove(previousOwner: Entity): void
  • Optional callback called when a component is removed from an entity


    Parameters

    Returns void

inheritedserialize

  • serialize(): Record<string, any>
  • Returns Record<string, any>

inheritedtoJSON

  • toJSON(pretty?: boolean): string
  • Parameters

    • pretty: boolean = false

    Returns string