I want to control something in my game with the Accelerometers sensor.

I don't know why but the getAzimuth doesnt works it always got the value 0, I made this test by showing the result of some methods and this is the output

Sample of Code :

font.draw(batch, "Gdx.input.getAccelerometerX() : " + String.valueOf(Gdx.input.getAccelerometerX()), 10, 200);

The output :

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

Other problem :

getAccelerometerX(), etc, works but even when the phone is lay on a table those numbers always changes

有帮助吗?

解决方案

Your device either doesn't have a compass, or you have disabled the compass in your AndroidApplicationConfiguration. In either of those cases getAzimuth(), getPitch(), and getRoll() will return 0.

其他提示

The accelerometer values show the device orientation to the ground. The azimuth according to geographical orientation (meaning magnetic north etc).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top