我正在使用最近的每日編譯的Corona SDK(版本2001.562)將陀螺儀支持添加到現有的應用程序。不幸的是,我似乎無法獲得用於陀螺儀發射的event-handling
功能。該應用程序在iPod touch上運行,版本4.3.3。來自Corona SDK的最新陀螺儀支持似乎不響應
我的陀螺儀連接到事件處理程序,像這樣:
if system.hasEventSource("gyroscope") then
feedbackFile = io.open(system.pathForFile("log.txt", system.DocumentsDirectory), "a");
feedbackFile:write((os.clock()-startupTime).."\tgyroscope on\n");
io.close(feedbackFile);
Runtime:addEventListener("gyroscope", onGyroscopeDataReceived)
else
feedbackFile = io.open(system.pathForFile("log.txt", system.DocumentsDirectory), "a");
feedbackFile:write((os.clock()-startupTime).."\tgyroscope off\n");
io.close(feedbackFile);
end
當我啓動設備上的應用程序,然後將其關閉並下載資源文件,我發現log.txt
包含與timestamp
行和「陀螺儀上」。目前很好!
在該事件處理函數:
local function onGyroscopeDataReceived(event)
feedbackFile = io.open(system.pathForFile("log.txt", system.DocumentsDirectory), "a");
feedbackFile:write((os.clock()-startupTime).."\tgyroscope reading delta="..event.deltaRotation..",x="..event.xRotation..",y="..event.yRotation..",z="..event.zRotation.."\n");
io.close(feedbackFile);
end
的信息,該行不會出現在log.txt
文件!
請指教。提前致謝!
我懷疑問題可能在於與我的設備,但我在另一個iPod touch 4.3.3版上試過上面的代碼,並得到了同樣令人失望的結果。 – JDT