event.xInstant

Type Number
Event accelerometer
Revision Release 2024.3703
Keywords accelerometer, xInstant

Overview

Provides the change of acceleration relative to the x-axis of the device’s screen in portrait orientation. This value is xGravity minus the previous xGravity reading, which provides the delta acceleration relative to zero.

The intent of this value is to detect if the device was “jerked” in a particular direction.

Gotchas

This value is always relative to the device in portrait orientation, regardless of the current orientation of your application. So, if your application is running in landscape mode, you’ll need to compensate by 90 degrees.

Example

local function onAccelerate( event )
    print( event.name, event.xInstant, event.yInstant, event.zInstant )
end
 
Runtime:addEventListener( "accelerometer", onAccelerate )