event.xRotation

类型 数字
事件 陀螺仪
修订内容 版本 2024.3703
关键字 陀螺仪,xRotation
另请参阅 event.yRotation
event.zRotation
event.deltaTime

概述

围绕设备x的旋转速率(单位:弧度/秒)。

须知事项

你可以使用以下公式将弧度转换为度数:

度数 = 弧度 * (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