Announcement: Tencent Cloud Mini Program Platform Renamed to Tencent Cloud Super App as a Service on January 2, 2025
Console Updates
Android SDK Updates
iOS SDK Updates
Flutter SDK Updates
IDE Updates
Base Library Updates
This API is used via wx.startAccelerometer(Object object).
interval and the actual execution frequency of the wx.onAccelerometerChange callback function.Attribute | Type | Default value | Required | Description |
interval | string | normal | No | Execution frequency of the callback function for monitoring acceleration data |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Value | Description |
game | Suitable for updating the callback frequency of the game, approximately every 20 ms. |
ui | Suitable for updating the callback frequency of the UI, approximately every 60 ms. |
normal | Regular callback frequency, approximately every 200 ms. |
wx.startAccelerometer({interval: 'game'})
This API is used via wx.stopAccelerometer(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
wx.stopAccelerometer()
This API is used via wx.onAccelerometerChange(function listener).
Attribute | Type | Description |
x | number | X-axis |
y | number | Y-axis |
z | number | Z-axis |
wx.onAccelerometerChange(function (res) {console.log(res.x)console.log(res.y)console.log(res.z)})
This API is used via wx.offAccelerometerChange(function listener).
const listener = function (res) { console.log(res) }wx.onAccelerometerChange(listener)wx.offAccelerometerChange(listener) // The same function object as the listener must be passed in.
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback