类型 数字 事件 陀螺仪 修订内容 版本 2024.3703 关键字 陀螺仪,xRotation 另请参阅 event.yRotation event.zRotation event.deltaTime
围绕设备
你可以使用以下公式将弧度转换为度数:
度数 = 弧度 * (180 / π)
-- Called when a new gyroscope measurement has been received local function onGyroscopeDataReceived( event ) -- Calculate approximate rotation traveled via delta time -- Remember that rotation rate is in radians per second local deltaRadians = event.xRotation * event.deltaTime local deltaDegrees = deltaRadians * (180/math.pi) end -- Set up the above function to receive gyroscope events if the sensor exists if system.hasEventSource( "gyroscope" ) then Runtime:addEventListener( "gyroscope", onGyroscopeDataReceived ) end