Skip to Content
defold-typescript libraries
britzl

britzl/defold-gyro/gyro

Gyroscope rotation for Defold on iOS and Android, delivered as a quaternion every frame.

  • GitHub: britzl/defold-gyro — pinned to 1.1.1
    1. Pick a release from britzl/defold-gyro releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as gyro from "gyro"

Functions

start(listener: (self: unknown, quatx: number, quaty: number, quatz: number, quatw: number) => void)

Starts the gyroscope. While started, the listener is invoked every frame with the device rotation as a quaternion.

Parameters

  • listener: (self: unknown, quatx: number, quaty: number, quatz: number, quatw: number) => void — Called every frame as (self, quatx, quaty, quatz, quatw).

stop()

Stops the gyroscope.

On this page