# wx.startAccelerometer(Object object)
Start from base library version 1.1.0. Please remaining backward compatible.
with Promise style call: Supported
Mini Program plugin: Support, need to Mini Program base library version no less than 1.9.6
Start monitoring the acceleration data.
# parameter
# Object object
attribute | type | Default values | Required | Introductions | Minimum version |
---|---|---|---|---|---|
interval | string | normal | no | Monitor the execution frequency of the acceleration data callback function | 2.1.0 |
success | function | no | Interface calls the successful callback function | ||
fail | function | no | Interface calls failed callback functions | ||
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.interval Legal value
value | Introductions | Minimum version |
---|---|---|
game | The callback frequency for updating the game, in 20ms/second About | |
ui | Apply to update UI Callback frequency of 60ms/second About | |
normal | Normal callback frequency, in the 200ms/second About |
# sample code
wx.startAccelerometer({
interval: 'game'
})
# Be careful
- Based on model performance, current CPU And the memory occupation,
interval
The setting and the actualwx.onAccelerometerChange()
There will be some variation in how often callback functions are executed.