本文介绍了OpenFL 从设备陀螺仪获取输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,所以我正在 OpenFL 和 Haxe.我想从陀螺仪收集输入,或者更具体地说是关于手机的方向.我已经搜索了 openfl 文档,并在谷歌上搜索了有关此类事情的某种文档或示例.我在那里不走运,想知道是否有人可以为我指出一些.
Okay, so I am working on a mobile app in OpenFL and Haxe. I would like to gather input from the gyroscope, or more specifically about the orientation of the phone. I have searched the openfl docs, and google for some kind of documentation or examples on this sort of thing. I had no luck there and would like to know if anyone could point me toward some.
推荐答案
制作一个新的加速度计:
Make a new Accelerometer:
private var _acc:Accelerometer = new Accelerometer();
给它添加一个事件监听器:
Add an event listener to it:
_acc.addEventListener(AccelerometerEvent.UPDATE, updateAcc);
听取结果:
Listen to results:
private function updateAcc(Event:AccelerometerEvent):Void
{
trace("x:" + Event.accelerationX);
trace("y:" + Event.accelerationY);
trace("z:" + Event.accelerationZ);
}
注意 iOS 加速度计值是反转的.
Note than iOS accelerometer values are inverted.
这篇关于OpenFL 从设备陀螺仪获取输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!