Swipe Up/Down/Left/Right

Get help using Construct 2

Post » Fri Jan 03, 2014 5:59 pm

I'd like to be able to swipe in either directions - up/down/left/right - and have a projectile launch from a character in that direction. How would this be done?
B
10
S
4
G
3
Posts: 103
Reputation: 2,984

Post » Fri Jan 03, 2014 6:10 pm

Make variables for touchstartx and touchstarty and check them against touch.x an touch.y to see the general direction of the movement is.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Jan 03, 2014 6:25 pm

[QUOTE=LittleStain] Make variables for touchstartx and touchstarty and check them against touch.x an touch.y to see the general direction of the movement is.[/QUOTE] Ok, there's a start. Many projectiles were created this way. so I did this:

"trigger once"                          create projectile
"touch 0 speed >5000"
     "touchstartx+300<touch.x"          set bullet speed...
                                        set bullet angle...

Sometimes this works, but mostly projectiles will only go the right. I have no idea why.
B
10
S
4
G
3
Posts: 103
Reputation: 2,984

Post » Fri Jan 03, 2014 6:40 pm

You'd probably need two comparisons per direction:

system compare two values: touch.x < touchstartx
system compare two values: abs(touchstartx-touch.x)<abs(touchstarty-touch.y)

would mean swipe left.


I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Jan 03, 2014 6:58 pm

Manual entry

AngleAt(index)
AngleForID(id)
Get the angle of motion of a specific touch in degrees by its zero-based index or unique ID. A touch must be moving across the device screen for this expression to contain a useful value.


You can also get the angle of your swipe with Touch.AngleAt()
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Fri Jan 03, 2014 7:08 pm

[QUOTE=lennaert] Manual entry

AngleAt(index)
AngleForID(id)
Get the angle of motion of a specific touch in degrees by its zero-based index or unique ID. A touch must be moving across the device screen for this expression to contain a useful value.


You can also get the angle of your swipe with Touch.AngleAt()[/QUOTE] I've read the entry and don't quite get the terminology. Do I just put a zero in the parenthesis?
B
10
S
4
G
3
Posts: 103
Reputation: 2,984

Post » Fri Jan 03, 2014 7:11 pm

the index nmbr is the nth touch

like

0 = first touch
1 = second
etc
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Fri Jan 03, 2014 8:18 pm

[QUOTE=lennaert] the index nmbr is the nth touch

like

0 = first touch
1 = second
etc[/QUOTE] Ok. I want this to work on every touch so I don't see this working. Unless it resets every time and the purpose is to keep track of fingers on the screen at the same time.
B
10
S
4
G
3
Posts: 103
Reputation: 2,984

Post » Sat Jan 04, 2014 8:30 am

No it doesnt keep counting them hahah.

Its a method to generally detect the second or third touch, like the double tap.

Generally youd be aiming for 0.

Just imagine if you use two fingers to swipe two different slab,one of the swipes would have 1 :)
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Sat Jan 04, 2014 7:15 pm

[QUOTE=lennaert] No it doesnt keep counting them hahah.

Its a method to generally detect the second or third touch, like the double tap.

Generally youd be aiming for 0.

Just imagine if you use two fingers to swipe two different slab,one of the swipes would have 1 :)[/QUOTE] That would make a lot more sense.

Anyway, I get all these concepts, but am still not sure exactly how to go about this. How do I create just one projectile per swipe?
B
10
S
4
G
3
Posts: 103
Reputation: 2,984

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 15 guests