Using accelerometer to change gravity

Using accelerometer to change gravity
0.0 0



In my game I have a character that you can move by either touching the screen left or right from him.

Now, I want to change the gravity depending on the way the user is holding his device. I’m printing the x-value of the accelerometervalue, but the value is always near 0 in landscape mode (both landscape left and right). I’m new to cocos2d-x and I have no idea how to continue, any tips?

Also, as I said, I move the character by touching left or right of him. I’m guessing that this will give problems when rotating the screen? for example if I change from landscape mode to portait and the character is at the bottom side of the screen, then it doesn’t matter if I press left or right of it as the touch will still be at the bottom of the screen (the touch event still thinks the device is in landscape mode?).
Yes, I could enable all device orientations in xcode, but then everything in my world rotates when I rotate the device. I only want to change the gravity and rotate my player character.

Thanks in advance, just ask if you need more info.