Difference between revisions of "Accelerometer.isAvailable"

From GiderosMobile
Line 1: Line 1:
The Accelerometer class is used to access accelerometer data.
+
Returns true if accelerometer is available for this platform, false otherwise.
  
 
<syntaxhighlight lang=lua>
 
<syntaxhighlight lang=lua>
--create instance
+
(bool) = Accelerometer.isAvailable()
local accelerometer = Accelerometer.new()
+
</syntaxhighlight>
--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
+
== Return value ==
accelerometer:stop()
+
bool: `true` if accelerometer is available for this platform, `false` otherwise.
</syntaxhighlight>
 

Revision as of 01:06, 22 August 2018

Returns true if accelerometer is available for this platform, false otherwise.

(bool) = Accelerometer.isAvailable()

Return value

bool: `true` if accelerometer is available for this platform, `false` otherwise.