停止监听加速度数据。
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
qq.stopAccelerometer()
开始监听加速度数据。
| 属性 | 类型 | 默认值 | 必填 | 说明 | 最低版本 |
|---|---|---|---|---|---|
| interval | string | normal | 否 | 监听加速度数据回调函数的执行频率 | |
| success | function | 否 | 接口调用成功的回调函数 | ||
| fail | function | 否 | 接口调用失败的回调函数 | ||
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
object.interval 的合法值
| 值 | 说明 |
|---|---|
| game | 适用于更新游戏的回调频率,在 20ms/次 左右 |
| ui | 适用于更新 UI 的回调频率,在 60ms/次 左右 |
| normal | 普通的回调频率,在 200ms/次 左右 |
qq.startAccelerometer({
interval: 'game'
})
interval 的设置与实际 qq.onAccelerometerChange 回调函数的执行频率会有一些出入。监听加速度数据事件。频率根据 qq.startAccelerometer() 的 interval 参数。可使用 qq.stopAccelerometer() 停止监听。
加速度数据事件的回调函数
Object res
| 属性 | 类型 | 说明 |
|---|---|---|
| x | number | X 轴 |
| y | number | Y 轴 |
| z | number | Z 轴 |
qq.onAccelerometerChange(function (res) {
console.log(res.x)
console.log(res.y)
console.log(res.z)
})