Need help with accelerometer and device orientation

TouchTiltGamesTouchTiltGames Member Posts: 1,162
edited November -1 in Working with GS (Mac)
My game I'm working on is designed to work in Portrait mode. It works in Portrait and Portrait upside down. I'm using accelerometer to control the actor's left and right movement. But here's my problem:

In 'Portrait Mode Upside Down': the game.Accelerometer.X works fine, but in just Portrait mode, it's backwards because the device is oriented different. So I need to tilt right to go left and tilt left to go right :P

So how does one set this up so no matter which of the two modes you're in, you can still tilt the iPad left to go left and tilt right to go right?

thanks a lot
shane

Comments

  • HymloeHymloe Member Posts: 1,653
    Hi there, you need to do a check for which Device>ScreenOrientation you are in, and switch the controls if the device has been flipped.

    So for example, you can say...

    If Accelerometer.Y < -0.1
    If Screen.InterfaceOrientation is Landscape Left
    Move left
    Otherwise, Move right

    If Accelerometer.Y > 0.1
    If Screen.InterfaceOrientation is Landscape Left
    Move right
    Otherwise, Move left

    I did something along those lines to get mine working just now.

    For some reason, Up and Down seemed to switch across appropriately on it's own, so yay!

    - Murray





  • HymloeHymloe Member Posts: 1,653
    Shame the indenting was deleted then. HMMM.. Anyway, should look more like this...

    If Accelerometer.Y < -0.1
    ___ If Screen.InterfaceOrientation is Landscape Left
    ______ Move left
    ___ Otherwise, Move right

    If Accelerometer.Y > 0.1
    ___ If Screen.InterfaceOrientation is Landscape Left
    ______ Move right
    ___ Otherwise, Move left
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Again, please dont bump old threads. This one is 2 years old as well.
This discussion has been closed.