event.yInstant

Type Number
Event accelerometer
Revision Release 2024.3703
Keywords accelerometer, yInstant

Overview

Provides the change of acceleration relative to the y-axis of the device's screen in portrait orientation. This value is yGravity minus the previous yGravity 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 )