How do I add touch swipe gestures?

Get help using Construct 2

Post » Tue Dec 15, 2015 10:03 pm

Hi guys!

So I'm currently making a mobile game where the player controls the character by swiping either left, right, up, or down to go those directions. I'm having some trouble with it though since those aren't possible events. I've tried throwing something together using angles and touch acceleration stuff but it won't go the right direction and when it does it moves it slightly off course. I've also made my character have the Car Direction Behaviour so it can travel a direction until it hits something, is that the best way to do this or is there something better? I've always struggled with proper movement in Construct for any other game I've made.

Here's a link to my capx so far, any advice would be appreciated.

https://dl.dropboxusercontent.com/u/264 ... otype.capx

Thanks guys!
B
7
S
3
Posts: 42
Reputation: 658

Post » Wed Dec 16, 2015 5:10 am

Hi, I've made a "flick" command for a game once. Doesn't know if this is what your are looking for.

But basically it works like this, I have a variable InitialY and a variable FinalY, every time the player touches the screen the position of his touch goes to InitialY, while the player is touching the screen the position he is touching goes to FinalY. So when the player lifts his finger of the screen I triggered a event to compare Initial and Final Y so I could know if the player have flicked up or down.

However for this game I've made possible only Up and Down flicks, you want vertical and diagonal too, so you will need two more variables for Initial and Final X, and depending on what you want to do a little bit more complex algorithm. But it is a idea, you should give it a try ^^
B
17
S
7
Posts: 277
Reputation: 2,514

Post » Wed Dec 16, 2015 4:00 pm

I was able to get swipe controls sort of working, except the player is offset by a pixel or so each move, so in the end the character is in the wrong place. What I eventually want is gameplay like the ice sections of Pokemon games, where you press a direction, the player slides that direction, and can't control themselves until they hit a wall, then you go another direction. This is where I need help now please. I almost want to have the player follow a grid since all movement will be horizontal or vertical but I'm not sure how to do this.

Here's my newest capx

https://dl.dropboxusercontent.com/u/264 ... otype.capx

Thanks guys!
B
7
S
3
Posts: 42
Reputation: 658


Return to How do I....?

Who is online

Users browsing this forum: eochranek, Exabot [Bot], Nicolas951 and 25 guests