tencent cloud

Feedback

Gyroscope

Last updated: 2024-11-21 18:48:11

    startGyroscope

    This API is used via wx.startGyroscope(Object object).
    Feature Description: Starts monitoring gyroscope data.
    Parameter and Description: 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)
    Valid values of object.interval
    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.

    stopGyroscope

    This API is used via wx.stopGyroscope(Object object).
    Feature Description: Stops monitoring gyroscope data.
    Parameter and Description: 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)

    onGyroscopeChange

    This API is used via wx.onGyroscopeChange(function callback).
    Feature Description: Monitors gyroscope data change events. The frequency depends on the interval parameter of wx.startGyroscope(). The monitoring can be stopped using wx.stopGyroscope().
    Parameter and Description: function callback, the callback function for gyroscope data change events. The arguments Object res are as follows:
    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.

    offGyroscopeChange

    This method is used via wx.offGyroscopeChange(function listener).
    Feature Description: Removes the listener function for gyroscope data change events.
    Parameter and Description: function listener, the listener function passed in by onGyroscopeChange. If this parameter is not passed in, all listener functions will be removed.
    Sample Code
    const listener = function (res) { console.log(res) }
    
    wx.onGyroscopeChange(listener)
    wx.offGyroscopeChange(listener) // The same function object as the listener must be passed in.
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support