How to detect Swipe direction/angle

Get help using Construct 2

Post » Mon Feb 04, 2013 4:00 pm

Hello,

I'm trying to use swipe control the player on touchscreen.

The "detecting touch speed" condition is very useful, but I also want the player move to the direction same as swipe direction. anybody know how to do this?
B
14
S
2
G
1
Posts: 94
Reputation: 2,089

Post » Mon Feb 04, 2013 5:56 pm

One way is to create variables to store the x,y values on touch start and on touch end and calculate an angle from those.

How you turn that into movement may depend on the behavior you have set for your player.
B
5
S
1
G
1
Posts: 12
Reputation: 899

Post » Mon Feb 04, 2013 6:21 pm

Thanks BenGIJOE. What if the swipe is a curve move? and I want the object move to the arrow direction in the picture.

B
14
S
2
G
1
Posts: 94
Reputation: 2,089

Post » Mon Mar 18, 2013 9:47 am

I am also looking for the same.

Example: swipe from left to right or right to left would bring up some sprite. And swipe from top to bottom or bottom to top would bring up some sprite.

Can anyone submit a capx?
B
9
S
3
G
1
Posts: 2
Reputation: 1,383

Post » Wed May 11, 2016 6:45 pm

porky wrote:Thanks BenGIJOE. What if the swipe is a curve move? and I want the object move to the arrow direction in the picture.

you can set a maximum offset for the x an y an so set max values for example:
Imagine a D pad, allow the finger to have a maximum miss swipe lets say that the player can follow. thus if the end point of the swipe is more then the allowed offset do either nothing or the other direction.
B
9
S
2
G
2
Posts: 24
Reputation: 1,670


Return to How do I....?

Who is online

Users browsing this forum: Unconnected and 15 guests