melonJS
    Preparing search index...

    Interface StickOptions

    A stick of the virtual gamepad.

    interface StickOptions {
        area?: ControlArea;
        base?: string;
        deadzone?: number;
        dpad?: boolean;
        dpadThreshold?: number;
        floating?: boolean;
        hideAtRest?: boolean;
        keys?: StickKeys;
        position?: Placement;
        radius?: number;
        side?: "left" | "right";
        tap?: StickTap;
        thumb?: string;
    }
    Index

    where a floating stick can be picked up: "half" (the default), its half of the screen; "screen", anywhere; or a rectangle { x, y, width, height } in viewport pixels. Buttons and fixed sticks come first where they overlap it (see ControlArea). Ignored for a fixed stick.

    base?: string

    the base region in the plugin's skin atlas; shapes when omitted

    deadzone?: number

    how far the stick must lean, from 0 to 1, before it reads anything. Past it the reading starts from 0, so it still reaches 1 at full travel. 0.1 by default, as input.setGamepadDeadzone.

    dpad?: boolean

    also press the D-pad buttons (GAMEPAD.BUTTONS.UP, DOWN, LEFT, RIGHT) in 8 directions as the stick leans. On by default for the left stick.

    dpadThreshold?: number

    how far the thumb must travel, from 0 to 1, to press the D-pad and its keys. 0.5 by default: half way.

    floating?: boolean

    the stick is centered where the thumb lands inside its area, rather than at a fixed spot, and goes back to its position when let go. Off by default.

    hideAtRest?: boolean

    draw a floating stick only while a finger holds it, so it appears under the thumb and is gone when the thumb lifts. Off by default: it rests in its corner, to show where it is. Ignored for a fixed stick.

    keys?: StickKeys

    keys to press, as the D-pad would, for a game that reads the keyboard rather than a pad

    position?: Placement

    where its center sits; the bottom corner on its side by default

    radius?: number

    the radius of its base, in viewport pixels

    side?: "left" | "right"

    which stick of a pad it is: "left" reports GAMEPAD.AXES.LX/LY, "right" reports RX/RY. The first stick is the left one, the second the right one.

    tap?: StickTap

    make a quick tap on the stick press a button or a key, as a button would: a touch that lifts within time and never leans far enough to press a direction (dpadThreshold) is a tap; a cancelled touch is not. The press lasts one frame, so a locked key fires once, and a fading ring marks where the tap landed. With a floating stick over the whole screen (area: "screen"), tap anywhere to act, drag to steer, and no button is needed. Off by default.

    thumb?: string

    the thumb region in the plugin's skin atlas; a circle when omitted