我想使用加速计传感器控制游戏中的某些内容。
我不知道为什么,但是getAzimuth不起作用它总是得到值0,我通过显示一些方法的结果进行了这个测试,这就是输出
代码示例:
font.draw(batch, "Gdx.input.getAccelerometerX() : " + String.valueOf(Gdx.input.getAccelerometerX()), 10, 200);
输出:
Gdx.input.getAccelerometerX() : -8.245
Gdx.input.getAccelerometerY() : 0.457
Gdx.input.getAccelerometerZ() : 1.245
Gdx.input.getAzimuth() : 0
Gdx.input.getPitch() : 0
Gdx.input.getRoll() : 0
其他问题:
getAccelerometerX() 等可以工作,但即使手机放在 table 上,这些数字总是会变化
最佳答案
您的设备没有指南针,或者您已在 AndroidApplicationConfiguration 中禁用指南针。无论哪种情况,getAzimuth()
、getPitch()
和 getRoll()
都将返回 0。
关于java - Libgdx getAzimuth() 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19714130/