Skip to content

sud.startGyroscope ​

JS
    sud.startGyroscope(Object object)

Starts listening for gyroscope data.

Calling startGyroscope repeatedly triggers the fail callback. Call stopGyroscope to stop first, then start again.

Parameters

  • Object object: Input parameters, see the table below for details

Properties of object:

PropertyTypeDefaultRequiredDescription
intervalstringnormalNoExecution interval of the gyroscope data callback function
successfunctionNoCallback function for a successful interface call
failfunctionNoCallback function for a failed interface call
completefunctionNoCallback function for the completion of the interface call (executed on both success and failure)

Valid values of interval:

ValueDescription
gameSuitable for game update callback frequency, around 20ms/time
uiSuitable for UI update callback frequency, around 60ms/time
normalNormal callback frequency, around 200ms/time

When the interval value is not one of the three values above, normal is used by default.

Parameters of the success callback function

  • Object res
PropertyTypeDescription
errMsgstring"startGyroscope:ok"

Parameters of the fail callback function

  • Object res
PropertyTypeDescription
errMsgstringError message