Options
All
  • Public
  • Public/Protected
  • All
Menu

Control class, handling all user inputs, both touch and via keyboard, as well as handling mouse movement.

Hierarchy

  • Controls

Index

Constructors

constructor

  • new Controls(navigatorMock?: any): Controls
  • Constructor of control class. Registers all event handlers.

    Parameters

    • Optional navigatorMock: any

      Mocked navigator object used for testing.

    Returns Controls

Properties

Private isMobileDevice

isMobileDevice: boolean

Are we currently on a mobile device? => Touch Controls!

Private lastMouseDeltaX

lastMouseDeltaX: number

How many pixels the mouse has moved since it's last moved

Private shootButton

shootButton: any = ...

Shoot button on the html page.

Private shootButtonRect

shootButtonRect: any

Vessel for location and dimensions of the shoot button on the html page.

states

states: Map<KeyCodes, boolean> = ...

States map. Records which key or action is activated at any given moment. Can be polled and updated. Clearing all values, ergo changing all values to false can be done using the clearInputs() method.

Static Readonly MOUSE_LOOK_SENSITIVITY

MOUSE_LOOK_SENSITIVITY: 20 = 20

Multiplier for mouse look sensitivity

Static Readonly TOUCH_LOOK_SENSITIVITY

TOUCH_LOOK_SENSITIVITY: 0.75 = 0.75

Multiplier for touch look sensitivity

Accessors

isMobile

  • get isMobile(): boolean

Methods

clearInputs

  • clearInputs(): void

getMouseDelta

  • getMouseDelta(): number

Private keyHandler

  • keyHandler(value: boolean, event: any): void
  • Handles key presses.

    Parameters

    • value: boolean

      Key code that was pressed.

    • event: any

      Event that gets passed from the listener.

    Returns void

Private mouseDownHandler

  • mouseDownHandler(event: any): void
  • Handles mouse clicks in case the mouse button gets pressed down.

    Parameters

    • event: any

      Event that gets passed from the listener.

    Returns void

Private mouseMoveHandler

  • mouseMoveHandler(event: any): void
  • Handles mouse look.

    Parameters

    • event: any

      Event that gets passed from the listener.

    Returns void

Private mouseUpHandler

  • mouseUpHandler(event: any): void
  • Handles mouse clicks in case the mouse button gets released.

    Parameters

    • event: any

      Event that gets passed from the listener.

    Returns void

Private touchHandler

  • touchHandler(event: any): void
  • Handles touch input. Gets called as soon as the screen is tapped.

    Parameters

    • event: any

      Event that gets passed from the listener.

    Returns void

Private touchReleaseHandler

  • touchReleaseHandler(event: any): void
  • Handles the end of touch input. Gets called as soon as the screen tap is released.

    Parameters

    • event: any

      Event that gets passed from the listener.

    Returns void

Generated using TypeDoc