Tilt control indicator
Approw
Member Posts: 703
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
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
Thanks for the response! but how do I connect those values to an indicator?
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)
Thats also a nice technique, but I want the indicator going left and righ in a bar
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.
Yes exactly! The device is in landscape mode left and right, do you have any code so the indicator can go left and right?
@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.
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.
This should help you out- http://gshelper.com/gs/progress1.2.zip
Chakku
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! ^:)^