How do I swipe left right ? up down?

Get help using Construct 2

Post » Mon Jun 08, 2015 12:28 am

hi,
i have a sprite with 4 frames
i would like to know how to when i swipe to left it change for example to frame 0
to the right to frame 1
up to frame 3
and down to frame 4 ?
the problem is how do i the swipe to left right up down ?
thanks
B
46
S
16
G
8
Posts: 802
Reputation: 8,351

Post » Mon Jun 08, 2015 4:39 am

up bump!
B
46
S
16
G
8
Posts: 802
Reputation: 8,351

Post » Mon Jun 08, 2015 6:31 am

I guess you need to store the coordinations on Tap and on release.
Then compare them both to determin whether it's going left/right/up/down.

On tap: Store Touch.X in locale variable InitialX
Store Touch.Y in locale variable InitialY
On release: Store Touch.X in locale variable ReleaseX
Store Touch.Y in locale variable ReleaseY
If Initial.X<Release.X: go to right
etc.

You might want to compare the difference of initial X and release X with the Y difference to prevent from going up while you are clearly going to the right. It is hard to touch and release on the same Y coordinate, vise versa with X.

gl!
It's time for me to return the favor :)
B
32
S
9
G
9
Posts: 132
Reputation: 5,375

Post » Mon Jun 08, 2015 6:34 pm

You can also use AngleAt on touch release - this gives you the angle of the swipe.
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Mon Jun 08, 2015 7:26 pm

paulscottrobson wrote:You can also use AngleAt on touch release - this gives you the angle of the swipe.


I didn't know that condition and it's great. Thanks paul :)
It's time for me to return the favor :)
B
32
S
9
G
9
Posts: 132
Reputation: 5,375

Post » Mon Jun 08, 2015 9:41 pm

One thing that amazes me about C2 is the number of times I think "I didn't know it could do that" :)
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Thu Jun 11, 2015 7:54 pm

ikke2902 wrote:I guess you need to store the coordinations on Tap and on release.
Then compare them both to determin whether it's going left/right/up/down.

On tap: Store Touch.X in locale variable InitialX
Store Touch.Y in locale variable InitialY
On release: Store Touch.X in locale variable ReleaseX
Store Touch.Y in locale variable ReleaseY
If Initial.X<Release.X: go to right
etc.

You might want to compare the difference of initial X and release X with the Y difference to prevent from going up while you are clearly going to the right. It is hard to touch and release on the same Y coordinate, vise versa with X.

gl!


:( sad
that not work properly
B
46
S
16
G
8
Posts: 802
Reputation: 8,351

Post » Thu Jun 11, 2015 9:54 pm

any help please?
B
46
S
16
G
8
Posts: 802
Reputation: 8,351

Post » Thu Jun 11, 2015 10:30 pm

matrixreal wrote::( sad that not work properly


What exactly does not work properly?
upload capx....
..........................................................
edit:
try this one> https://app.box.com/s/aly34ql8h4teoy50f7tz3wpkgfsh42ef
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Fri Jun 12, 2015 3:09 pm

@matrixreal You should try the more elegant solution suggested by paulscot
Here is my capx using his idea
https://dl.dropboxusercontent.com/u/152 ... angle.capx

gl!
It's time for me to return the favor :)
B
32
S
9
G
9
Posts: 132
Reputation: 5,375

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests