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

Implements

Constructors

Properties

dependencies: (typeof TransformComponent | typeof MotionComponent)[] = ...

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: "ex.actions" = 'ex.actions'

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

Methods

  • This method will cause an actor to blink (become visible and not visible). Optionally, you may specify the number of blinks. Specify the amount of time the actor should be visible per blink, and the amount of time not visible. This method is part of the actor 'Action' fluent API allowing action chaining.

    Parameters

    • timeVisible: number

      The amount of time to stay visible per blink in milliseconds

    • timeNotVisible: number

      The amount of time to stay not visible per blink in milliseconds

    • Optional numBlinks: number

      The number of times to blink

    Returns ActionContext

  • This method allows you to call an arbitrary method as the next action in the action queue. This is useful if you want to execute code in after a specific action, i.e An actor arrives at a destination after traversing a path

    Parameters

    • method: (() => any)
        • (): any
        • Returns any

    Returns ActionContext

  • This method will delay the next action from executing for a certain amount of time (in milliseconds). This method is part of the actor 'Action' fluent API allowing action chaining.

    Parameters

    • time: number

      The amount of time to delay the next action in the queue from executing in milliseconds

    Returns ActionContext

  • This method will cause an actor's opacity to change from its current value to the provided value by a specified time (in milliseconds). This method is part of the actor 'Action' fluent API allowing action chaining.

    Parameters

    • opacity: number

      The ending opacity

    • time: number

      The time it should take to fade the actor (in milliseconds)

    Returns ActionContext

  • This method will move an actor by the specified x offset and y offset from its current position, at a certain speed. This method is part of the actor 'Action' fluent API allowing action chaining.

    Parameters

    • offset: Vector

      The (x, y) offset to apply to this actor

    • speed: number

      The speed in pixels per second the actor should move

    Returns ActionContext

  • This method will move an actor by the specified x offset and y offset from its current position, at a certain speed. This method is part of the actor 'Action' fluent API allowing action chaining.

    Parameters

    • xOffset: number

      The x offset to apply to this actor

    • yOffset: number

      The y location to move the actor to

    • speed: number

      The speed in pixels per second the actor should move

    Returns ActionContext

  • This method will move an actor to the specified x and y position at the speed specified (in pixels per second) and return back the actor. This method is part of the actor 'Action' fluent API allowing action chaining.

    Parameters

    • pos: Vector

      The x,y vector location to move the actor to

    • speed: number

      The speed in pixels per second to move

    Returns ActionContext

  • This method will move an actor to the specified x and y position at the speed specified (in pixels per second) and return back the actor. This method is part of the actor 'Action' fluent API allowing action chaining.

    Parameters

    • x: number

      The x location to move the actor to

    • y: number

      The y location to move the actor to

    • speed: number

      The speed in pixels per second to move

    Returns ActionContext

  • This method will cause the actor to repeat all of the actions built in the repeatBuilder callback. If the number of repeats is not specified it will repeat forever. This method is part of the actor 'Action' fluent API allowing action chaining

    // Move up in a zig-zag by repeated moveBy's
    actor.actions.repeat(repeatCtx => {
    repeatCtx.moveBy(10, 0, 10);
    repeatCtx.moveBy(0, 10, 10);
    }, 5);

    Parameters

    • repeatBuilder: ((repeatContext: ActionContext) => any)

      The builder to specify the repeatable list of actions

    • Optional times: number

      The number of times to repeat all the previous actions in the action queue. If nothing is specified the actions will repeat forever

    Returns ActionContext

  • This method will cause the actor to repeat all of the actions built in the repeatBuilder callback. If the number of repeats is not specified it will repeat forever. This method is part of the actor 'Action' fluent API allowing action chaining

    // Move up in a zig-zag by repeated moveBy's
    actor.actions.repeat(repeatCtx => {
    repeatCtx.moveBy(10, 0, 10);
    repeatCtx.moveBy(0, 10, 10);
    }, 5);

    Parameters

    • repeatBuilder: ((repeatContext: ActionContext) => any)

      The builder to specify the repeatable list of actions

    Returns ActionContext

  • This method will rotate an actor by the specified angle offset, from it's current rotation given a certain speed in radians/sec and return back the actor. This method is part of the actor 'Action' fluent API allowing action chaining.

    Parameters

    • angleRadiansOffset: number

      The angle to rotate to in radians relative to the current rotation

    • speed: number

      The speed in radians/sec the actor should rotate at

    • Optional rotationType: RotationType

      The RotationType to use for this rotation, default is shortest path

    Returns ActionContext

  • This method will rotate an actor to the specified angle at the speed specified (in radians per second) and return back the actor. This method is part of the actor 'Action' fluent API allowing action chaining.

    Parameters

    • angleRadians: number

      The angle to rotate to in radians

    • speed: number

      The angular velocity of the rotation specified in radians per second

    • Optional rotationType: RotationType

      The RotationType to use for this rotation

    Returns ActionContext

  • This method will scale an actor by an amount relative to the current scale at a certain speed in scale units/sec and return back the actor. This method is part of the actor 'Action' fluent API allowing action chaining.

    Parameters

    • offset: Vector

      The scaling factor to apply to the actor

    • speed: number

      The speed to scale at in scale units/sec

    Returns ActionContext

  • This method will scale an actor by an amount relative to the current scale at a certain speed in scale units/sec and return back the actor. This method is part of the actor 'Action' fluent API allowing action chaining.

    Parameters

    • sizeOffsetX: number

      The scaling factor to apply on X axis

    • sizeOffsetY: number

      The scaling factor to apply on Y axis

    • speed: number

      The speed to scale at in scale units/sec

    Returns ActionContext

  • This method will scale an actor to the specified size at the speed specified (in magnitude increase per second) and return back the actor. This method is part of the actor 'Action' fluent API allowing action chaining.

    Parameters

    • size: Vector

      The scale to adjust the actor to over time

    • speed: Vector

      The speed of scaling specified in magnitude increase per second

    Returns ActionContext

  • This method will scale an actor to the specified size at the speed specified (in magnitude increase per second) and return back the actor. This method is part of the actor 'Action' fluent API allowing action chaining.

    Parameters

    • sizeX: number

      The scaling factor to apply on X axis

    • sizeY: number

      The scaling factor to apply on Y axis

    • speedX: number

      The speed of scaling specified in magnitude increase per second on X axis

    • speedY: number

      The speed of scaling specified in magnitude increase per second on Y axis

    Returns ActionContext