need help with accelerometercontrol behavior in portrait mode

rdcuberdcube Member Posts: 361
edited November -1 in Working with GS (Mac)
Hi y'all,
I've seen a couple of apps made with GS (Jumpo, and doodle crash to name a couple) that makes the character move by tilting the device left and right.

I followed some video that TSB made a couple of months ago on implementing accelerometer in your games.

There is also a couple of templates/demos that show this feature, as well as the wiki.

They all work and I managed to make them work on my device as well. X/Y (or left/right, up/down) tilt work perfect.

My main question/problem is, we always set X/Y to +/- 0.1 or something to that effect, which works perfectly if you have the device laying flat on it's back and you tilt around, so the 'ball' moves perfectly along the device/screen (granted you have set your friction, density, etc, accordingly).

What I want to do instead, is have the device straight up (completely standing up portrait position), have a character (let's call it 'ball') which will be positioned not completely down (about 1/4 of the bottom of the screen/device...I assume this is like a -1 for the Y)

What I would like to do, is that once the device is straight up ( | ), I need to tilt the device just about 10~20 degress ( / ) away from user ( something like this: | to this / ); once the device is tilt, have the 'ball' move 'up' and if you tilt back (or towards you) again, it slowly moves 'down' instead of just dropping (I played with gravity, but this affects the rest of my characters as wel).

Hope all this rumbling makes sense...I'm trying and trying with no luck.

If anybody could please wipe up a quick 'template/demo', or just provide some clear defined direction on how to do this, I would highly appreciate it.

Thanks
rdcube

Comments

  • Rob2Rob2 Member Posts: 2,402
    20 degrees leaning back in portrait causes Y to go from -1.0 to -0.9 at the same time Z goes from -0.16 to -0.50
  • Rob2Rob2 Member Posts: 2,402
    roughly :)
  • Rob2Rob2 Member Posts: 2,402
    so can't you just check for values?
  • rdcuberdcube Member Posts: 361
    I am checking for values and seeing how Y is being treated, but whenever I do if accel.Y < - 0.9 it doesn't work, if I do if accel.Y > -0.9 nothing...not even changing to Y < 0.9 or Y > 0.9

    I also started wondering how this will affect the orientation, meaning, Apple now wants the games to rotate up/down or left/right while maintaining all same =S
  • Rob2Rob2 Member Posts: 2,402
    you want to be using Z
  • rdcuberdcube Member Posts: 361
    The Z option is not working either...

    anyone? please!!!
  • Rob2Rob2 Member Posts: 2,402
    It worked for me...I will post the project
  • IntelligentDesignerIntelligentDesigner Member Posts: 517
    Try the excellent (and free) app "iDevices" by fellow GS'er JD Leach
  • Rob2Rob2 Member Posts: 2,402
    I can't upload a portrait game file to GS but it's very straightforward, here is an image of the two rules to move an actor up and down when you tilt back and forward holding your device in vertical portrait (they are both Z)

    http://i43.tinypic.com/ofoq5g.png

    the actor starts at the bottom of the screen
  • rdcuberdcube Member Posts: 361
    @rob2,
    AWESOME.

    I think the deal is that I was using 'accelerate' and ur using 'move to'...although, not as smooth move as I want, it seems to be getting the work done.

    Do you mind letting me know the coordinate for X (left - right)?

    Would I need a Y at all?

    Any recommendation on friction, density and restition?

    Thanks again.
  • Rob2Rob2 Member Posts: 2,402
    nice to be useful for once instead of my normal moaning!! been away and no real time now I'm afraid, but there is a sample xcode project which is very useful when trying to work out the best way of dealing with the accelerometer and that idevices app looks useful.

    this helped me a while back http://www.geekpedia.com/PageView3010_iPhone-Tutorial---Reading-the-Accelerometer.html

    and having a new look in the apple iphone os reference library (wow it's good) search for AccelerometerGraph or similar!!
Sign In or Register to comment.