문제

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