Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
A nice method to read gyroscope values — Gideros Forum

A nice method to read gyroscope values

gorkemgorkem Maintainer
edited January 2012 in Code snippets

This code snippet can be used to read gyro values
require "gyroscope"
 
gyroscope:start()
 
local angx = 0
local angy = 0
local angz = 0
local function onEnterFrame(event)
    local x, y, z = gyroscope:getRotationRate()
 
    angx = angx + x * event.deltaTime
    angy = angy + y * event.deltaTime
    angz = angz + z * event.deltaTime
 
    print(angz * 180 / math.pi)
end
 
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)
Tagged:

Comments

Sign In or Register to comment.