Difference between revisions of "Accelerometer"
From GiderosMobile
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | + | [[Category:Main API]] | |
− | |||
<languages /> | <languages /> | ||
<!-- GIDEROSOBJ:Accelerometer --> | <!-- GIDEROSOBJ:Accelerometer --> |
Revision as of 14:43, 6 December 2019
Supported platforms:
Available since: Gideros 2012.8
Inherits from: Object
Description
The Accelerometer class is used to access accelerometer data.
Examples
Example
local filter = 0.03
local fx, fy, fz = 0, 0, 0
--create instance
local accelerometer = Accelerometer.new()
--start receiving data
accelerometer:start()
function onEnterFrame(event)
---get values for example on each enter frame event
local x, y, z = accelerometer:getAcceleration()
fx = x * filter + fx * (1 - filter)
fy = y * filter + fy * (1 - filter)
fz = z * filter + fz * (1 - filter)
print("Y: "..math.floor(fy*90*-1))
print("X: "..math.floor(fx*90*-1))
print("Z: "..math.floor(fz*90*-1))
end
stage:addEventListener("enterFrame",onEnterFrame,self)
MethodsAccelerometer.isAvailable is the accelerometer available? |
EventsConstants |