Gleam - v1.0.2
    Preparing search index...

    Class ControllerCursor

    On-screen crosshairs driven by a Controller's analog sticks. Each anchor in sticks gets its own crosshair that follows the corresponding stick's deflection with frame-rate-independent exponential smoothing (50 ms half-life). The caller owns the anchor positions and the crosshair image — any CanvasImageSource works (a loaded HTMLImageElement, a procedurally-drawn HTMLCanvasElement, an ImageBitmap, …).

    update polls the controller for you; don't call Controller.poll again from the same update step.

    Index

    Constructors

    Methods

    Constructors

    • Parameters

      • controller: Controller

        Gamepad input source.

      • crosshair: CanvasImageSource

        Drawn at each cursor position via CanvasRenderingContext2D.drawImage. The image's top-left is the draw origin — center the visible reticle inside the image, or offset the anchors to compensate.

      • sticks: Vec2[]

        Anchor positions, one per stick to track. Cloned at construction so caller mutation is harmless.

      • range: number = 80

        Max pixel deflection from anchor at full stick. Default 80.

      Returns ControllerCursor

    Methods

    • Draw a crosshair at anchor + offset for each tracked stick.

      Parameters

      • context: CanvasRenderingContext2D

      Returns void

    • Pull fresh stick state via Controller.poll and smooth each crosshair's offset toward stickAxis * range. Frame-rate independent — 50 ms to cover half the remaining distance.

      Parameters

      • dt: number

      Returns void