This API is used via wx.startGyroscope(Object object).
Attribute | Type | Default value | Required | Description |
interval | string | normal | No | Execution frequency of the callback function for monitoring gyroscope 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. |
This API is used via wx.stopGyroscope(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) |
This API is used via wx.onGyroscopeChange(function callback).
Attribute | Type | Description |
x | number | Angular velocity of the x-axis. |
y | number | Angular velocity of the y-axis. |
z | number | Angular velocity of the z-axis. |
This method is used via wx.offGyroscopeChange(function listener).
const listener = function (res) { console.log(res) }wx.onGyroscopeChange(listener)wx.offGyroscopeChange(listener) // The same function object as the listener must be passed in.
Was this page helpful?