Class ButtonInput

The ButtonInput class models a button which can be pressed or released. Pressure-sensitive buttons are also supported, with changes in pressure announced through the changed ButtonEvent.

Hierarchy

  • ButtonInput

Constructors

  • Parameters

    • name: string

      The name property allows for an easy way to identify a button when it may be one of many buttons available.

    Returns ButtonInput

Properties

changed: ButtonEvent = ...

This event is fired every time the button remains being pressed, but changes how hard it's being pressed.

pressed: ButtonEvent = ...

This event is fired every time the button switches state from not being pressed, to being pressed.

released: ButtonEvent = ...

This event is fired every time the button switches state from being pressed, to not being pressed.

valueTracker: PropertyTracker<number>

Tracks changes to the button's state.

Accessors

  • get activeMs(): number
  • Returns how many consecutive milliseconds the button has been held pressed for. If the button is not currently pressed, this will return 0.

    Returns number

  • get isPressed(): boolean
  • Returns whether the button is currently pressed.

    Returns boolean

  • get name(): string
  • The name property allows for an easy way to identify a button when it may be one of many buttons available.

    Returns string

  • get typeName(): string
  • Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable.

    Returns string

  • get value(): number
  • Returns the current value of the button.

    Returns number

Methods

  • This method is intended to be called by a clock to provide regular updates. It should not be called by consumers of the library.

    Returns

    Parameters

    • deltaMs: number

      How many milliseconds have passed since the last update cycle.

    Returns void

Generated using TypeDoc