swapAxis accelerometer bug?

  ... in the unlikely case you discovered a bug, post it here.

swapAxis accelerometer bug?

Postby pd » Fri Nov 11, 2011 8:50 pm

I have a problem with HTC Desire and accelerometer orientation, sometimes I get x and y axis inverted (x becomes -x and y becomes -y, so accelerometer sprite control is inverted).

These are my engine options:

final EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera).setNeedsSound(true);

I traced a problem to this file:

/src/org/anddev/andengine/sensor/accelerometer/AccelerometerData.java

The problem is that sometimes mDisplayRotation is 3 (ROTATION_270) so axis are inverted in swapAxis function.

I am not sure why sometimes I get 270 orientation (usually it's 90 as it should be). It happens maybe in 10% cases, usually after I compile and run from eclipse.

Any ideas?
pd
 
Posts: 15
Joined: Thu Jul 28, 2011 11:13 am

Re: swapAxis accelerometer bug?

Postby crinkledink » Sat Nov 19, 2011 12:53 pm

hey i recall this bug to exist in all honeycombdevices but first time i heard about it in non 3.0 device. are you stating landscape in your manifest?
crinkledink
 
Posts: 129
Joined: Sun May 15, 2011 6:26 pm

Re: swapAxis accelerometer bug?

Postby pd » Sat Nov 19, 2011 1:12 pm

crinkledink wrote:hey i recall this bug to exist in all honeycombdevices but first time i heard about it in non 3.0 device. are you stating landscape in your manifest?


I don't state landscape in manifest, but it was never a problem with 1.6 device, only sometimes with 2.2...

Anyway, I solved that by commenting out this condition in Engine.java in enableAccelerometerSensor function:

if(this.mAccelerometerData == null) {...

so every time I call enableAccelerometerSensor (at the start of level) I get updated (correct) orientation. Previously orientation data was obtained only initially, and sometimes it was wrong data (timing issue with setting and getting orientation, I guess).
pd
 
Posts: 15
Joined: Thu Jul 28, 2011 11:13 am


Return to Bugs

Who is online

Users browsing this forum: No registered users and 5 guests