Class Controller

Constructors

Properties

MAX_LAYER: number = 1999998

The maximum layer

tween: any = ...

A reference to the tween instance this controller uses to tween the alpha when it becomes inactive. This reference is so that developers can pause this tween and resume it when needed. Calling this.tween.pause() and this.tween.resume() for instance when pausing and unpausing the game.

joyring: null | DiobElement = null

The joyring element of this controller.

joystick: null | DiobElement = null

The joystick element of this controller.

version: string = "VERSION_REPLACE_ME"

The version of the module.

options: null | ControllerOptions = null

The options of this controller.

lockedDimension: null | "both" | "vertical" | "horizontal" = null

The locked dimension of the joystick. both | vertical | horizontal. This is used to lock the joystick from moving in certain dimensions. If this joystick's type is traversal it cannot be locked.

zone: null | "left" | "right" = null

The zone the joystick will occupy. If there is already a controller of the traversal or static type, then you must use a zone. If there is only one controller no zone is needed. left | right This will give each controller equal space on the left | right sides of the screen.

activeInZone: boolean = false

Whether this controller is active in zone. e.g the controller is zoned to the left, and the user taps on the left side of the screen.

controllingFinger: null | number = null

The fingerID that is controlling the joystick.

active: boolean = false

Whether this controller is active

onRelease: null | ((client, angle) => void) = null

Event function for when the joystick is released.

Type declaration

    • (client, angle): void
    • Parameters

      • client: any
      • angle: number

      Returns void

onMove: null | ((client, normalizedX, normalizedY, angle, inCenter) => void) = null

Event function for when the joystick is moved.

Type declaration

    • (client, normalizedX, normalizedY, angle, inCenter): void
    • Parameters

      • client: any
      • normalizedX: number
      • normalizedY: number
      • angle: number
      • inCenter: boolean

      Returns void

Methods

  • Setup the controller with the options that this controller class instance has from being initiated

    Returns void

  • Tweens the controller to it's inactive alpha preset, or from it's inactive value preset to full alpha.

    Parameters

    • pFade: boolean

      Whether to fade the joystick to it's inactive alpha preset

    Returns void

  • Resets the joystick to default.

    Parameters

    • pSoft: boolean

      Softly resets the joystick in the event it is hidden

    Returns void

  • Builds this controller with the options that were passed in.

    Parameters

    Returns void

  • Returns the type of this controller.

    Returns "stationary" | "traversal" | "static"

    Returns the type of this controller.

  • Updates the controllers position with the latest information from touch events

    Parameters

    • pX: number

      The x position on the screen where the user tapped.

    • pY: number

      The y position on the screen where the user tapped.

    • Optional pTouchStart: boolean

      If this was the first time the joystick was touched.

    Returns void

  • API called when this joystick is released

    Parameters

    • Optional pForce: boolean

      If this was a forced release. Called progamatically.

    Returns void

  • Locks a joystick from moving in a certain dimension or both

    Parameters

    • Optional pDimension: string

      The dimension to lock. both | vertical | horizontal

    Returns void

  • Unlocks the joystick from being locked in the passed dimension.

    Parameters

    • Optional pDimension: string

      The dimension to unlock. both | vertical | horizontal

    Returns void

  • Returns the components that make up this controller. Which are the joystick element, and the joyring element.

    Returns null | {
        joystick: DiobElement;
        joyring: DiobElement;
    }

    An object containing references to the joytick and the joyring that makeup this controller.