event.yRotation

类型 数字
事件 gyroscope
修订时间 2024.3703 版
关键字 gyroscope, yRotation
另请参阅 event.xRotation
event.zRotation
event.deltaTime

概览

绕设备的y的每秒弧度数旋转速率。

提示

您可以通过以下公式将弧度转换为角度

角度 = 弧度 * (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.yRotation * 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