sud.startDeviceMotionListening
JS
sud.startDeviceMotionListening(Object object)开始监听设备方向的数据。调用了此api,在未调用stopDeviceMotionListening情况下再次调用此api将返回失败。
参数
- Object object: 传入参数,具体的属性见下表
object 的属性说明:
| 属性 | 键值类型 | 默认值 | 是否必填 | 说明 |
|---|---|---|---|---|
| interval | string | normal | 否 | 监听设备方向数据回调函数的执行频率 |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数 |
interval 的合法值:
| 值 | 说明 |
|---|---|
| game | 适用于更新游戏的回调频率,在 20ms/次 左右 |
| ui | 适用于更新 UI 的回调频率,在 60ms/次 左右 |
| normal | 普通的回调频率,在 200ms/次 左右 |
当interval参数值不是以上三个值时候,则会默认使用normal。
