X Accelerometer Introduction

From GiderosMobile
Revision as of 00:05, 22 August 2018 by Anthony (talk | contribs) (Created page with "The Accelerometer class is used to access accelerometer data. <syntaxhighlight lang=lua> --create instance local accelerometer = Accelerometer.new() --start receiving data ac...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The Accelerometer class is used to access accelerometer data.

--create instance
local accelerometer = Accelerometer.new()
--start receiving data
accelerometer:start()
---get values for example on each enter frame event
local x, y, z = accelerometer:getAcceleration()
print(x, y, z)

--once you don't need it, stop it
accelerometer:stop()