Excalibur leverages the HTML5 Gamepad API where it is supported to provide controller support for your games.

Hierarchy

Constructors

Properties

enabled: boolean = false

Whether or not to poll for Gamepad input (default: false)

eventDispatcher: EventDispatcher<any>

Direct access to the game object event dispatcher.

supported: boolean = !!(<any>navigator).getGamepads

Whether or not Gamepad API is supported

MinAxisMoveThreshold: number = 0.05

The minimum value an axis has to move before considering it a change

Methods

  • Safely retrieves a Gamepad at a specific index and creates one if it doesn't yet exist

    Parameters

    • index: number

    Returns Gamepad

  • Gets the number of connected gamepads

    Returns number

  • Emits a new event

    Parameters

    • eventName: string

      Name of the event to emit

    • eventObject: any

      Data associated with this event

    Returns void

  • Alias for removeEventListener. If only the eventName is specified it will remove all handlers registered for that specific event. If the eventName and the handler instance are specified only that handler will be removed.

    Parameters

    • eventName: string

      Name of the event to listen for

    • Optional handler: ((event: Events.GameEvent<any, any>) => void)

      Event handler for the thrown event

    Returns void

  • Once listens to an event one time, then unsubscribes from that event

    Parameters

    • eventName: string

      The name of the event to subscribe to once

    • handler: ((event: any) => void)

      The handler of the event that will be auto unsubscribed

        • (event: any): void
        • Parameters

          • event: any

          Returns void

    Returns void

  • Sets the minimum gamepad configuration, for example {axis: 4, buttons: 4} means this game requires at minimum 4 axis inputs and 4 buttons, this is not restrictive all other controllers with more axis or buttons are valid as well. If no minimum configuration is set all pads are valid.

    Parameters

    Returns void

  • Updates Gamepad state and publishes Gamepad events

    Returns void