×
A new build of Corona SDK is now available to subscribers. Not a subscriber? Subscribe now.
CoronaSDK 2014.2281 | Released: 24 Apr 2014, 1:58am | What's New | Download Now

event.xRotation

Description:

Gets the rotation rate around the device's x-axis in radians per second.

Syntax:

value = event.xRotation

Example:

-- Called when a new gyroscope measurement has been received.
local function onGyroscopeDataReceived( event )
    -- Calculate approximate rotation traveled via deltaTime.
    -- 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

Parameters:

None

Returns:

number

Returns the rotation rate in radians per second where values are positive in the counter-clockwise direction.

Remarks:

You can convert radians to degrees via the following formula:
degrees = radians * (180 / pi)

Supported on operating systems and platforms for build numbers shown:
  • Mac OS X:
    --
  • Windows:
    --
  • iOS:
    2011.544
  • Android:
    2011.544