Making "Gravity" dependent on iPhone orientation

jon2sjon2s Member Posts: 40
edited November -1 in Working with GS (Mac)
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!

Comments

  • pnvgordinhopnvgordinho Member Posts: 21
    hello, A year ago ORBZ recommended this line of code....

    accelerate: vectorToAngle(device.accelerometerY, device.accelerometerX * -1)

    Im also trying to do something like you but I still havent found the correct formula.
  • jb15jb15 Member Posts: 602
    pnvgordinho said:
    Im also trying to do something like you but I still havent found the correct formula.

    +1
  • RedlerTechRedlerTech Member Posts: 1,583
    Tshirtbooth has showed us in the past - http://gamesalad.com/forums/topic.php?id=16774#post-127647

    Matt :D
  • jb15jb15 Member Posts: 602
    Thanks nextgen! My issue has actually been solved.

    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.
  • RedlerTechRedlerTech Member Posts: 1,583
    :D no prob, thank Tshirt too!

    Matt
  • jb15jb15 Member Posts: 602
    NextGen said:
    :D no prob, thank Tshirt too!

    Matt

    Yeah, thanks tshirt! :)
Sign In or Register to comment.