سؤال

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