Difference between revisions of "Accelerometer"
From GiderosMobile
(test adding it to main api category) |
(creating category test) |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
+ | |||
<languages /> | <languages /> | ||
+ | |||
<!-- GIDEROSOBJ:Accelerometer --> | <!-- GIDEROSOBJ:Accelerometer --> | ||
− | ''' | + | '''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform winrt.png]]<br/> |
− | ''' | + | '''Available since:''' Gideros 2012.8<br/> |
− | ''' | + | '''Inherits from:''' [[Special:MyLanguage/Object|Object]]<br/> |
− | === | + | === Description === |
− | + | The [[Special:MyLanguage/Accelerometer|Accelerometer]] class is used to access accelerometer data. | |
+ | <br/> | ||
− | === | + | === Examples === |
− | |||
<source lang="lua"> | <source lang="lua"> | ||
local filter = 0.03 | local filter = 0.03 | ||
Line 31: | Line 33: | ||
stage:addEventListener("enterFrame",onEnterFrame,self) | stage:addEventListener("enterFrame",onEnterFrame,self) | ||
</source> | </source> | ||
+ | <br/> | ||
{|- | {|- | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
− | === | + | === Methods === |
− | [[Special:MyLanguage/Accelerometer.isAvailable|Accelerometer.isAvailable]] '' | + | [[Special:MyLanguage/Accelerometer.isAvailable|Accelerometer.isAvailable]] ''is the accelerometer available?''<br> |
− | + | [[Special:MyLanguage/Accelerometer.new|Accelerometer.new]] ''creates new Accelerometer instance''<br/> | |
− | [[Special:MyLanguage/Accelerometer.new|Accelerometer.new]] '' | + | [[Special:MyLanguage/Accelerometer:getAcceleration|Accelerometer:getAcceleration]] ''returns the 3-axis acceleration measured by the accelerometer''<br/> |
− | + | [[Special:MyLanguage/Accelerometer:start|Accelerometer:start]] ''starts accelerometer updates''<br/> | |
− | [[Special:MyLanguage/Accelerometer:getAcceleration|Accelerometer:getAcceleration]] '' | + | [[Special:MyLanguage/Accelerometer:stop|Accelerometer:stop]] ''stops accelerometer updates''<br/> |
− | |||
− | [[Special:MyLanguage/Accelerometer:start|Accelerometer:start]] '' | ||
− | |||
− | [[Special:MyLanguage/Accelerometer:stop|Accelerometer:stop]] '' | ||
− | |||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
− | === | + | === Events === |
− | === | + | === Constants === |
|} | |} | ||
+ | <br/> | ||
[[Category:Main API]] | [[Category:Main API]] |
Revision as of 08:16, 2 December 2019
Supported platforms:
Available since: Gideros 2012.8
Inherits from: Object
Description
The Accelerometer class is used to access accelerometer data.
Examples
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 |