(English from translator probably some word is wrong lol)
hey guys, I’m doing a school work using corona, i use gps speed to fire a simple image and song, but this extremely inaccurate, 90% times it returns 0 speed, even if i run with my cellphone, heres the code:
-----------------------------------------------------------------------------------------
--
-- main.lua
--
-----------------------------------------------------------------------------------------
--SCRIPT POR KKRAFT PARA TRABALHO DE CIENCIAS!
local fundo = display.newImage("fundo.png")
local img = display.newImage("rosto.png")
local imghappy = display.newImage("rostohappy.png")
--Inicio
fundo.width = 10000
fundo.height = 10000
img.width = 350
img.height = 300
imghappy.width = 350
imghappy.height = 300
imghappy.isVisible = false
img.x = display.contentCenterX - 5
img.y = display.contentCenterY
imghappy.x = display.contentCenterX - 5
imghappy.y = display.contentCenterY
--Vibração
local function acelerometro(event)
if event.zGravity >= 0.1 or event.xGravity >= 0.1 then
system.vibrate( )
end
end
local function speedfunc(event)
print( event.speed )
if event.speed >= 0.0001 then
local enginefx = audio.loadSound( "alfa-romeo-c.mp3")
audio.play(enginefx,{duration=1900})
imghappy.isVisible = true
img.isVisible = false
end
end
local function reset()
imghappy.isVisible = false
img.isVisible = true
end
imghappy:addEventListener( "touch", reset )
Runtime:addEventListener("accelerometer", acelerometro )
Runtime:addEventListener( "location", speedfunc )
Please help me i have to bring it to the teacher Monday