Tilt control indicator

Hi all,

Does anybody know how to create an indicator that shows how far you tilt the device left or right?
I want a bar with a dot in the middle so it can slide left and right to show the player how far they tilt the device.

Matthias

Comments

  • sparkaniasparkania Member, PRO Posts: 300
    Constrain scene real to the tilting actor's self.rotation then add an actor with a Display Text displaying the value of that scene real
  • ApprowApprow Member Posts: 703
    @sparkania

    Thanks for the response! but how do I connect those values to an indicator?
  • sparkaniasparkania Member, PRO Posts: 300
    edited January 2013
    create in the scene tab a 'real' called "Tilt"
    on your tilting actor, add a block Constrain Attribute, Constrain: scene.tilt to: self.rotation
    create a new actor called 'meter', add it to the scene and add a block Display Text and set the text to scene.tilt
    this will produce a text number which shows what angle the tilted actor has tilted to.

    that scene.tilt can also be used to adjust anything you need (like adjusting the x movement of a dot indicator)
  • ApprowApprow Member Posts: 703
    edited January 2013
    @sparkania
    Thats also a nice technique, but I want the indicator going left and righ in a bar
  • SocksSocks London, UK.Member Posts: 12,822
    @sparkania

    I think he wants to access the accelerometer.


    @matthiasstoopman . . . an indicator that shows how far you tilt the device left or right?"

    Which orientation would the device be in when you tilt it left and right (it matters) - you can obviously tilt an iPad left and right when it's held in portrait mode, when in landscape mode and when flat.

    But essentially you just constrain the dot's X position to a multiple of one of the accelerometer values.
  • sparkaniasparkania Member, PRO Posts: 300
    edited January 2013
    I just realized that I misread your post.. tilt the 'Device' I mistook as an actor...
  • ApprowApprow Member Posts: 703
    edited January 2013
    @Socks
    Yes exactly! The device is in landscape mode left and right, do you have any code so the indicator can go left and right?
  • sparkaniasparkania Member, PRO Posts: 300
    I dont know enough about the output values associated with the accelerometers..
  • ApprowApprow Member Posts: 703
    @sparkania okay thanks for your help anyway!

    @Socks Its basicly just for the final touch of my new game, its almost finished. I think its a nice feature. I'm not begging for some code, but it wil save me a lot of time to figure out how that works.

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2013
    @Socks
    Yes exactly! The device is in landscape mode left and right, do you have any code so the indicator can go left and right?

    Constrain the 'dot's' X position to: 512+(game.Accelerometer.Y *512)

    That's basically it !

    This is for an iPad (which GS sees as 1024 pixels wide) - you can adjust the values for whatever device you are using, if it's an iPhone5 (which GS sees as 568 pixels wide) then it would be:

    Constrain the 'dot's' X position to: 284+(game.Accelerometer.Y *284) . . .

    etc etc.


    This will see your dot sweep from extreme left to extreme right, if you would rather limit the range a little - just lower the final figure (in red below).

    512+(game.Accelerometer.Y *512.
  • ChakkuChakku Member Posts: 1,513
  • ApprowApprow Member Posts: 703
    @Socks Thanks it works! altough it was a bit choppy how the dot moves from left to the right. This method works very smooth

    Timer: every 0 seconds and do not check run to completion.
    -Interpolate: Self,position.X to 512+(Game.Accelerometer.Y*300)


    If the screen is rotated to the other side change it to this:
    - Self,position.X to 512+(-Game.Accelerometer.Y*300)

    just put a minus after the first bracked, the 300 is so the dot isnt moving extreme left and right.

    Thanks Socks! ^:)^
Sign In or Register to comment.