Difference between revisions of "X Accelerometer Introduction"

From GiderosMobile
Line 1: Line 1:
 
The Accelerometer class is used to access accelerometer data.
 
The Accelerometer class is used to access accelerometer data.
  
<source lang="lua">
+
<zzz>
 
--create instance
 
--create instance
 
local accelerometer = Accelerometer.new()
 
local accelerometer = Accelerometer.new()
Line 12: Line 12:
 
--once you don't need it, stop it
 
--once you don't need it, stop it
 
accelerometer:stop()
 
accelerometer:stop()
</source>
+
</zzz>

Revision as of 09:56, 22 August 2018

The Accelerometer class is used to access accelerometer data.

<zzz> --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() </zzz>