The method of utilizing this API is wx.stopDeviceMotionListening(Object object).
Attributes | Types | Default value | Required | Note |
success | function | - | Not required | Callback function for successful interface invocation |
fail | function | - | Not required | Callback function for unsuccessful interface invocation |
complete | function | - | Not required | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
The method for utilizing this API is wx.startDeviceMotionListening(Object object)
Attributes | Types | Default value | Required | Note |
interval | string | normal | Not required | The execution frequency of the callback function monitoring device orientation changes, valid values are: game: Suitable for updating the callback frame rate of the game, approximately every 20ms. ui: Suitable for updating the callback frame rate of the UI, approximately every 60ms. normal: Regular callback frequency, approximately every 200ms. |
success | function | - | Not required | Callback function for successful interface invocation |
fail | function | - | Not required | Callback function for unsuccessful interface invocation |
complete | function | - | Not required | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
The usage method for this API is wx.onDeviceMotionChange(function listener)
Attributes | Types | Note |
alpha | number | When the X/Y coordinates of the mobile device coincide with the X/Y coordinates of the Earth, the angle of rotation around the Z-axis is alpha, with a range of [0, 2*PI). Counterclockwise rotation is positive. |
beta | number | When the Y/Z coordinates of the mobile device coincide with the Y/Z coordinates of the Earth, the angle of rotation around the X-axis is beta, with a range of [-1*PI, PI). Rotation with the top facing the Earth's surface is positive. It may also be positive when facing the user. |
gamma | number | When the X/Z coordinates of the mobile device coincide with the X/Z coordinates of the Earth, the angle of rotation around the Y-axis is gamma, with a range of [-1*PI/2, PI/2). Rotation with the right side facing the Earth's surface is positive. |
The usage of this API is wx.offDeviceMotionChange(function listener).
const listener = function (res) { console.log(res) }wx.onDeviceMotionChange(listener)wx.offDeviceMotionChange(listener) // The same function object as used during monitoring must be passed in.
Was this page helpful?