Function watchAccelerometer

  • Enable monitor of the device accelerator to detect the amount of physical force of acceleration the device is receiving. (one some device a first user gesture will be required before calling this function)

    Returns boolean

    false if not supported or permission not granted by the user

    device

    • device.accelerationX
    • device.accelerationY
    • device.accelerationZ
    // try to enable device accelerometer event on user gesture
    me.input.registerPointerEvent("pointerleave", me.game.viewport, function() {
    if (me.device.watchAccelerometer() === true) {
    // Success
    me.input.releasePointerEvent("pointerleave", me.game.viewport);
    } else {
    // ... fail at enabling the device accelerometer event
    }
    });