Touch & Rotation

Get help using Construct 2

Post » Tue Apr 03, 2012 1:49 pm

Is there a way I can get an object to rotate in the direction of where I touch?

So if I touch on the right of an iPad screen, the object will look right.

I already have the simulated 8-directional movement attached, but the object/player should also rotate in the same direction of its movement.
B
11
S
2
Posts: 127
Reputation: 1,532

Post » Tue Apr 03, 2012 2:27 pm

To look make an object look at where you touch, make sure you have both the object and the Touch object ready.

You then create the event on the event sheet "On Touch Start", which is found under Touch. You then add the action "Set angle toward position", found under the object you wish to rotate. It will then ask you for the X and Y coordinates for the position. In X put "Touch.X" and in Y type "Touch.Y". That should work!

This will only have the object face your Touch once. If you want it to continually turn to your touch, make the event "Is in Touch" instead.

(Just a quick tip, which I didn't learn until a few days trying, you can set the Touch object to treat Mouse clicks as Touch taps. This is in the properties tab for Touch. This way you can test the program on the computer instead of having to transfer it over all the time!)
B
29
S
4
Posts: 42
Reputation: 2,391

Post » Tue Apr 03, 2012 2:32 pm

wow. Thanks so much. I have changed the setting to now use mouse input.

I have been using a brilliant plugin called TouchMouse, which works great. But in this instance, its not suited.

Thanx AgainPixiefingers2012-04-03 14:49:08
B
11
S
2
Posts: 127
Reputation: 1,532

Post » Wed Apr 04, 2012 4:17 am

I'm also finding a way to implement this, would you be kind enough to supply us with a .CAPX sample demonstrating this touch rotation. Thank you in advanced...
B
82
S
11
G
8
Posts: 153
Reputation: 10,215

Post » Wed Apr 04, 2012 4:51 am

Try:
is in touch
set angle to anglelerp(self.angle,angle(self.x,self.y,touch.x,touch.y),1-0.5^dt)
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767


Return to How do I....?

Who is online

Users browsing this forum: makkancs and 23 guests