Pro Swipe Formula for Mobiles

Get help using Construct 2

Post » Mon Jul 30, 2012 10:39 pm

Hey everyone, do you know about pro swipe? it's more than d-pad and analog stick, it's designed for mobiles with touch support.


We create an invisible sprite for the whole screen it should to detect our fingers according the directions, if you swipe up, the character moves up, then you swipe down, the character moves down, swipe right, the caracter moves right. It shouldn't stop moving while touching is busy, when the touch ends, the character stops.


Do you have an idea?
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Tue Jul 31, 2012 8:42 am

@Joannesalfa : I didn't played Mage Gauntlet on iOS, but it's known for that kind of mechanism (perhaps you played it yourself, and it's given you the idea ? ).
I would do it like that :
- every X milliseconds, set a "Starting Point" var as the current (Touch.X, Touch.Y)
- X milliseconds, check the new (Touch.X1, Touch.Y1)
- do a check :
IF ((X1-X) > threshold, (X1-X) > 0, AND (Y1-Y) < variationOnAxis),
THEN Move 10 pixels to the right.
IF ((X1-X) < threshold, (X1-X) < 0, AND (Y1-Y) < variationOnAxis),
THEN Move 10 pixels to the left.
IF ((X1-X) < variationOnAxis, AND (Y1-Y) > threshold, (Y1-X) > 0),
THEN Move 10 pixels to the bottom.
IF ((X1-X) < variationOnAxis, AND (Y1-Y) < threshold, (Y1-X) < 0),
THEN Move 10 pixels to the top.

The idea is to 1) set a variation on the vertical or horizontal axis that allows the player to draw lines that aren't "exactly" vertical or horizontal, and 2) check if his finger has moved farther than a pre-determined threshold in one of those direction.
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Tue Jul 31, 2012 8:51 pm

[QUOTE=Pode] @Joannesalfa : I didn't played Mage Gauntlet on iOS, but it's known for that kind of mechanism (perhaps you played it yourself, and it's given you the idea ? ).
I would do it like that :
- every X milliseconds, set a "Starting Point" var as the current (Touch.X, Touch.Y)
- X milliseconds, check the new (Touch.X1, Touch.Y1)
- do a check :
IF ((X1-X) > threshold, (X1-X) > 0, AND (Y1-Y) < variationOnAxis),
THEN Move 10 pixels to the right.
IF ((X1-X) < threshold, (X1-X) < 0, AND (Y1-Y) < variationOnAxis),
THEN Move 10 pixels to the left.
IF ((X1-X) < variationOnAxis, AND (Y1-Y) > threshold, (Y1-X) > 0),
THEN Move 10 pixels to the bottom.
IF ((X1-X) < variationOnAxis, AND (Y1-Y) < threshold, (Y1-X) < 0),
THEN Move 10 pixels to the top.

The idea is to 1) set a variation on the vertical or horizontal axis that allows the player to draw lines that aren't "exactly" vertical or horizontal, and 2) check if his finger has moved farther than a pre-determined threshold in one of those direction.[/QUOTE]


Yes, it's inspired by Mage Gauntlet on iOS.

I'm going to try out your idea, so i hope it will be worked.
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Thu Aug 02, 2012 7:34 am

Actually, i failed to attempt your formula...

Do we will use 8 dir movement behavior that simulates movement according to TouchY and TouchX?
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Thu Aug 02, 2012 8:13 am

Would you make a .capx example? it would be awesome!
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Thu Aug 02, 2012 6:23 pm

Heres an example I made showing player movement with swipe motions. Swipe anywhere on the game window to move the player. The longer the swipe the longer the player moves

Live Demo

capx here

it includes pretty much everything already set up to use the swipe data for whatever
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Thu Aug 02, 2012 9:56 pm

[QUOTE=aridale] Heres an example I made showing player movement with swipe motions. Swipe anywhere on the game window to move the player. The longer the swipe the longer the player moves

Live Demo

capx here

it includes pretty much everything already set up to use the swipe data for whatever[/QUOTE]

I was hoping for your awesome example, actually it's not exactly "Pro Swipe" because when you do "Touching" then swipe, it does nothing until touch ends it moves.


In event number 2, i changed "On Touched End" to "Is in Touch" it works as pro swipe but not precisely, you can simulate touch using Chrome.


Do your mouse makes a circle movement while click is holding it may act as touching.


Do you have an idea how to stop moving character when touching is end?
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Thu Aug 02, 2012 10:16 pm

bMove is the instance var on the player that controls it movin. That gets set to false when movetime is >= the time based on the touch distance

And yeah it doesnt move if you just touch and not swipe because theres a global controlling it. If the distance between touch start and touch end isnt greater than that threshold it doesnt trigger movementaridale2012-08-02 22:17:48
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Thu Aug 02, 2012 10:49 pm

[QUOTE=aridale] bMove is the instance var on the player that controls it movin. That gets set to false when movetime is >= the time based on the touch distance

And yeah it doesnt move if you just touch and not swipe because theres a global controlling it. If the distance between touch start and touch end isnt greater than that threshold it doesnt trigger movement[/QUOTE]

Thanks a lot for clearing that! :)

B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Mon Mar 18, 2013 9:54 am

I am also looking for similar solution.

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

Next

Return to How do I....?

Who is online

Users browsing this forum: makkancs, Matthew de and 39 guests