类型 数字 事件 陀螺仪 版本 发布 2024.3703 关键词 陀螺仪, zRotation 另请参阅 event.xRotation event.yRotation event.deltaTime
围绕设备的旋转速率
可通过下列公式将弧度转换成角度
角度 = 弧度 * (180 / pi)
-- 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.zRotation * 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