Swipe like iOS

Get help using Construct 2

Post » Tue Dec 04, 2012 7:26 pm

Hi, been searching but haven't found any good caps on any example on how to swipe the screen and it scrolls and then slows down..

You know what i mean right ??

Thankful if anyone out there has a good example.

cheers !!
B
12
S
2
G
5
Posts: 31
Reputation: 3,494

Post » Tue Dec 04, 2012 9:29 pm

Well here are some suggestions.

A.
1. Store Touch.X/Y when originally pressed.
2. On release compare distance and angle of start and end.

B
1. while in touch
2. every 10ms(choose your own time for repsonse) store X/Y
2. on the 10ms compare distance and angle. then store new X/Y coord.

in either method do what you want with angle and distance :)

B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Tue Dec 04, 2012 10:32 pm

I did a full feature slot game. Took me 2 weeks. Then I added swipe left/right to bring in settings and info screens, which could also be swiped up down. Took me more than 6 weeks. The result was a disaster of unmanageable code. I gave up with he project, although it was complete and 100 sexy, no way to maintain it, and it had a number of small swipe glitches (e.g. if you start swiping on a button, and finish swiping off a button, that cant count as a button press, so you have to manually manage all your own buttons - what a pain). I went the route of creating several layers, each with its own panel, then the game starts, I move them all off to the left and right just outside the visible area. The game handled different screen sizes, so this was variable. This is a very difficult way to go. If I had to do it again, I might try one big layout, with huge gaps between each "screen" filled with background to allow for different widths and heights of mobile devices. I also found that any kind of swiping ran at about 1fps on the iphone 3 and 3gs, and was not great on 4 (around 25fps). Looked fantastic on 4s and Ipad 3 though. Probably the biggest single most challenge to doing this is the fact that buttons get touch events even though they are hidden below other layers and even made visible. This requires some very quirky logic to figure out which buttons should be pressable during and after swipe events. This cannot be fixed with the enabling/disabling groups. I would advise against any form of swipe. Do it with buttons until C2 gets swipe support (which also works with pressing buttons) and the ability to make buttons disabled.
I animated the swipe by pinning all the screens items to one object. Then I use the bullet behaviour on that. I had 4 invisible pixel object on each screen so I know if it had gone the right distance left/right/up/down. Then you have to move it back to exactly the right place as stopping a bullet leaves it in a random place.nutmix2012-12-04 22:41:19
B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Wed Dec 05, 2012 10:57 pm

@nutmix:

I wanted to try making swipe with buttons, so I threw together an example. Here's the link if you're interested:

SwipeWithButtons.capx (r111)
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Sun Feb 03, 2013 9:59 pm

@Nimtrix: this is great for me right now, thank you for sharing!
B
17
S
3
G
5
Posts: 71
Reputation: 4,401

Post » Sun May 19, 2013 6:25 am

Hi,
I have written a tutorial on how to get swipe based smooth layout scrolling with inertia (gradual slow down). Check it out here: https://www.scirra.com/tutorials/560/swipe-based-smooth-scrolling-with-inertiaabhishan2013-05-19 06:26:39
B
27
S
6
G
6
Posts: 20
Reputation: 6,132

Post » Sat Jul 06, 2013 2:41 pm

[QUOTE=Nimtrix] @nutmix:

I wanted to try making swipe with buttons, so I threw together an example. Here's the link if you're interested:

SwipeWithButtons.capx (r111)[/QUOTE]

Let me just say, thank you!
It's simple, ellegant and efficient... perfect!

B
26
S
11
G
2
Posts: 669
Reputation: 5,038

Post » Sun Dec 08, 2013 8:25 am

@Nimtrix
hi
after adding sliding menu my levels buttons disappearing after win (press first button) I know it because of global variables, if i set levels buttons global to "NO" (in properties) they not disappearing, but not working levels
Please help me make level buttons not disappearing
https://www.dropbox.com/s/tifimk1a18ppe8e/menu_var.capx
Image
B
14
S
6
G
5
Posts: 99
Reputation: 3,825

Post » Sun Dec 08, 2013 3:28 pm

@Nimtrix
A thousand thank you's for sharing the file!
These examples teach me way more than the dedicated task. Your generosity allows me to learn way more than you realize.
Much appreciation here!
B
20
S
2
Posts: 257
Reputation: 2,431


Return to How do I....?

Who is online

Users browsing this forum: makkancs and 29 guests