Nemesis
Nemesis

Reputation: 25

Accelerometer not working well in all devices

This is a pretty open question.

We developed a game for android using Andengine. Zombies come at you and they "grab" you, and to shake them off, you have to move the device. There is a bug present in several devices where one cannot shake the zombies by moving the device. We cannot replicate this error on the devices we have for testing the game.

So my question is: Could there be a possibility of the hardware not being fully compatible with certain android functions ? I mean there is a sea of android devices out there.

I ask this question in order to have a better idea of how to proceed. Should we dig the programming further(as we have been doing, unsuccessfully) or implement a different way to shake the zombies(without the accelerometer).

Thanks in advance

Here is the game for if someone wants to get a better idea of the bug https://play.google.com/store/apps/details?id=com.exmgames.cfdesperationlite

Upvotes: 1

Views: 376

Answers (1)

nayab
nayab

Reputation: 2380

Issue may be with frequency of Accelerometer.Dont use below android constants while registering.

mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);

these valuse are different for different device. i.e ex: SENSOR_DELAY_UI gives 100Hz in one device and 50Hz in another and 125Hz in another. always use Hardcoded frequency rates.

int SENSOR_DELAY_FASTEST    get sensor data as fast as possible
int SENSOR_DELAY_GAME   rate suitable for games
int SENSOR_DELAY_NORMAL rate (default) suitable for screen orientation changes
int SENSOR_DELAY_UI rate suitable for the user interface

Use Hard coded values in microseconds like for frequency 1 Hz

mSensorManager.registerListener(this, mAccelerometer,1000000);

Hope it solves.

Upvotes: 1

Related Questions