How Would I Make a Steering Wheel?

Get help using Construct 2

» Wed Jul 17, 2013 3:12 am

I'm trying to figure out how to make a steering wheel.

I've thought of setting the angle to where I touch, but that just makes it jump to the position, and I've tried using how far I've dragged the touch but then the action is the opposite direction on the other side of the wheel.

Any ideas?

Any help is appreciated.
Follow me on Twitter @evgLabs
B
34
S
14
G
4
Posts: 251
Reputation: 4,074

» Wed Jul 17, 2013 4:02 am

Off hand you could try the rotate method I used in this topic.
http://www.scirra.com/forum/resize-handles-example_topic54023_post378368.html#378368

There may be other topics that have ways to rotate knobs that may help.
B
100
S
38
G
134
Posts: 5,553
Reputation: 85,319

» Wed Jul 17, 2013 10:26 am

For this to work, you will need a variable to store the angle offset of the start of touch :
When the touch starts, you calculate the current angle between your wheel and the touch. Let's call this Alpha, Alpha = angle(wheel.X,wheel.Y,touch.X,touch.Y)-wheel.initialAngle
(wheel.initialAngle is the angle of the wheel when the touch starts)
Then, while the touch is active, you set the sprite angle to angle(wheel.X,wheel.Y,touch.X,touch.Y) - Alpha
This will make the wheel follow the touch (as the current angle will change just as the touch angle changes), and when the touch starts, the angle will be set to Wheel.initialAngle (so it won't jump to the current touch angle)Guizmus2013-07-17 10:27:45
B
17
S
9
G
4
Posts: 473
Reputation: 6,321

Return to How do I....?

Who is online

Users browsing this forum: sonicwiz and 1 guest