Making "Gravity" dependent on iPhone orientation

Just curious if anyone has done this and if they have any pointers. I would like use either the new built in gravity or another method to create in scene gravity that is based off of the orientation of the iPhone/iPod/iPad.
So if the orientation is portrait and is nearly vertical there would be heavy gravity going to the bottom of the screen. If the device is at a 45 degree angle, the gravity is pointing at that lowest corner. Also if the device is laying flat on a table there is no real gravity going any direction.
I would think that there has to be a method to do something like this but honestly I have not messed with the accelerometer values yet and am just looking for some pointers before I get going.
Thanks!
So if the orientation is portrait and is nearly vertical there would be heavy gravity going to the bottom of the screen. If the device is at a 45 degree angle, the gravity is pointing at that lowest corner. Also if the device is laying flat on a table there is no real gravity going any direction.
I would think that there has to be a method to do something like this but honestly I have not messed with the accelerometer values yet and am just looking for some pointers before I get going.
Thanks!
Comments
accelerate: vectorToAngle(device.accelerometerY, device.accelerometerX * -1)
Im also trying to do something like you but I still havent found the correct formula.
Matt
I just did the labrynth demo for the 4th or 5th time, and realized I could just reverse the direction of the ball--so it goes up when I when normally I'd want it to go up. I knew the answer had to be simple.
Matt