Gamepad holds state information for a connected controller. See Gamepads for more information on handling controller input.

Hierarchy

Constructors

Properties

connected: boolean = false
eventDispatcher: EventDispatcher<any>

Direct access to the game object event dispatcher.

navigatorGamepad: NavigatorGamepad

Methods

  • Emits a new event

    Parameters

    • eventName: string

      Name of the event to emit

    • eventObject: any

      Data associated with this event

    Returns void

  • Gets the given axis value between -1 and 1. Values below MinAxisMoveThreshold are considered 0.

    Parameters

    Returns number

  • Tests if a certain button is held down. This is persisted between frames.

    Parameters

    • button: Buttons

      The button to query

    • threshold: number = 1

      The threshold over which the button is considered to be pressed

    Returns boolean

  • Whether or not the given button is pressed

    Deprecated

    will be removed in v0.28.0. Use isButtonHeld instead

    Parameters

    • button: Buttons

      The button to query

    • threshold: number = 1

      The threshold over which the button is considered to be pressed

    Returns boolean

  • 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: any) => void)

      Event handler for the thrown event

        • (event: any): void
        • Parameters

          • event: any

          Returns void

    Returns void

  • Alias for addEventListener. You can listen for a variety of events off of the engine; see the events section below for a complete list.

    Parameters

    • eventName: string

      Name of the event to listen for

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

      Event handler for the thrown event

        • (event: any): void
        • Parameters

          • event: any

          Returns void

    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

  • Parameters

    • axesIndex: number
    • value: number

    Returns void

  • Parameters

    • buttonIndex: number
    • value: number

    Returns void

  • Tests if a certain button was just pressed this frame. This is cleared at the end of the update frame.

    Parameters

    • button: Buttons

      Test whether a button was just pressed

    • threshold: number = 1

      The threshold over which the button is considered to be pressed

    Returns boolean

  • Tests if a certain button was just released this frame. This is cleared at the end of the update frame.

    Parameters

    • button: Buttons

      Test whether a button was just released

    Returns boolean