PokéRogue
    Preparing search index...

    Handles the dragging of touch controls around the screen.

    Index

    Constructors

    Properties

    configurationEventListeners: ConfigurationEventListeners = ...

    The event listeners for the configuration mode. These are used to remove the event listeners when the configuration mode is disabled.

    draggingElement: null | HTMLElement = null

    The element that is currently being dragged

    inConfigurationMode: boolean

    Whether the user is currently configuring the touch controls. When this is true, the touch controls can be dragged around the screen and the controls of the game are disabled.

    isLandscapeMode: boolean = ...
    overlay: Container
    touchControls: TouchControl

    Methods

    • Creates the event listeners for the configuration mode.

      Parameters

      • controlGroups: HTMLDivElement[]

        The elements that can be dragged around the screen.

      Returns ConfigurationEventListeners

      The event listeners for the configuration mode.

    • Creates an overlay that covers the screen and allows the user to drag the touch controls around. Also enables the toolbar for saving, resetting, and canceling the changes.

      Parameters

      • ui: UI

        The UI of the game.

      Returns void

    • Returns the references to the elements of the configuration toolbar.

      Returns undefined | ToolbarRefs

      The references to the elements of the configuration toolbar or undefined if the elements can not be found (e.g. during tests)

    • Returns the current positions of all touch controls that have moved from their default positions of this orientation.

      Returns ControlPosition[]

      The current positions of all touch controls that have moved from their default positions of this orientation

    • Returns the saved positions of the touch controls. Filters result by the given orientation.

      Returns ControlPosition[]

      The saved positions of the touch controls of this orientation

    • Elements that are inside the left div are anchored to the left boundary of the screen. The x value of the positions are considered offsets to their respective boundaries.

      Parameters

      • element: HTMLElement

        Either an element in the left div or the right div.

      Returns undefined | boolean

      Whether the given element is inside the left div.

    • Sets a control element to the given position. The x values are either offsets to the left or right boundary of the screen, depending on the side of the element. E.g. For left elements, (0, 0) is the bottom left corner of the screen and for right elements, (0, 0) is the bottom right corner of the screen.

      Parameters

      • controlElement: HTMLElement
      • x: number

        Either an offset to the left or right boundary of the screen.

      • y: number

        An offset to the bottom boundary of the screen.

      Returns void