Accelerometer Readings Get Swapped Sometimes

I'm trying to make a game in which I want a yellow circle (sprite) to move in the canvas based on device orientation using accelerometer (I'm not using orientation sensor on purpose).
I want the game to be in landscape, so I set screen orientation to landscape.

When I ran the app, it worked as intended. The ball was moving in the direction in which I tilted the phone.
But then I accidentally pressed the back button. When I opened the app again (Note: the app was running in background; It didn't close completely), it started behaving weirdly. When I tilt down it goes leftwards, when I tilt right it goes downwards.
Also, this happens 70-80% of the time, not always. I'm I the only who is facing the issue. Please anyone let me know what to do.

.aia file: copy.aia (3.2 KB)
My Device: GIONEE P7 (Android 6.0)

In this extension

Use the OnPause Event to detect the app close. If closed set the ball speed to 0.

1 Like

Hello Kaustubh

While your App is running, it can take command of the Back Button - so set it to do nothing.

BackButton

1 Like

or just like this
Unbenannt

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

1 Like

The reason I put 'something' in the Back Pressed Block is to emphasis the Block is there for a reason.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.