Options
All
  • Public
  • Public/Protected
  • All
Menu

Module utils/ControlManager

Index

Type Aliases

Control: { buttons: Button | Button[]; halt?: boolean; on_down?: Function; on_up?: Function; params?: { loop_time?: number; reset_controls?: boolean }; sfx?: { down?: string | (() => string); up?: string | (() => string) } }

Type declaration

  • buttons: Button | Button[]

    The button that will fire the callbacks. If it's an array, the buttons will be tested if pressed in order.

  • Optional halt?: boolean

    Stop propagation of the event, blocking the dispatch to next listener on the queue. Does not work for loops.

  • Optional on_down?: Function
  • Optional on_up?: Function
  • Optional params?: { loop_time?: number; reset_controls?: boolean }
    • Optional loop_time?: number

      Time between each trigger on button held

    • Optional reset_controls?: boolean

      Will reset all controls that were set together upon this button press. Double check it usage when "no_initial_reset" was set to true in further controls. Only works if "persist" is false.

  • Optional sfx?: { down?: string | (() => string); up?: string | (() => string) }
    • Optional down?: string | (() => string)

      The sfx to be played on key down. You can also pass a function the returns the sfx key.

    • Optional up?: string | (() => string)

      The sfx to be played on key up. You can also pass a function the returns the sfx key.

ControlParams: { call_once?: boolean; loop_config?: { horizontal?: boolean; horizontal_time?: number; shoulder?: boolean; shoulder_time?: number; vertical?: boolean; vertical_time?: number }; no_initial_reset?: boolean; persist?: boolean }

Type declaration

  • Optional call_once?: boolean

    The passed callbacks will be called just once and then automatically unbound. ControlManager.reset has no effect over it. Use ControlManager.detach_bindings to detach bindings in the case it's not necessary to call the callbacks anymore. If this parameter is true, "persist", "reset_controls" and "no_initial_reset" have no effect. Don't work for loops.

  • Optional loop_config?: { horizontal?: boolean; horizontal_time?: number; shoulder?: boolean; shoulder_time?: number; vertical?: boolean; vertical_time?: number }
    • Optional horizontal?: boolean
    • Optional horizontal_time?: number
    • Optional shoulder?: boolean
    • Optional shoulder_time?: number
    • Optional vertical?: boolean
    • Optional vertical_time?: number
  • Optional no_initial_reset?: boolean

    Whether to reset the current controls before attaching new ones. Only works for controls set with "persist" false. When setting this to true, use it wiselly.

  • Optional persist?: boolean

    Whether the bindings set must persist even if ControlManager.reset is called. If true, ControlManager.detach_bindings need to be called to disable these controls.

SimpleControlParams: { confirm_only?: boolean; no_initial_reset?: boolean; persist?: boolean; reset_on_press?: boolean; sfx?: string }

Type declaration

  • Optional confirm_only?: boolean

    If true, only button A will receive the callback. Otherwise button B also receives.

  • Optional no_initial_reset?: boolean

    Whether to reset the current controls before attaching new ones. Only works for controls set with "persist" false. When setting this to true, use it wiselly.

  • Optional persist?: boolean

    Whether the bindings set must persist even if ControlManager.reset is called. If true, ControlManager.detach_bindings need to be called to disable these controls.

  • Optional reset_on_press?: boolean

    Will reset all controls that were set together upon this button press. Double check it usage when "no_initial_reset" was set to true in further controls. Only works if "persist" is false.

  • Optional sfx?: string

    The sfx to be played upon button pressed.

Generated using TypeDoc