Touch swipe right

Hey all,

How do i make a swipe right with touch? And when swiped right, the object moves.
I looked on the forum if i could find anything on this subject. Some topics where from GD4. And i tried some code from a few topics, but without succes. Does someone know how to do this? Or has an example in their own game.

Thanks in advance!

Initially keep track of where and when the touch start occurs. On touch end, calculate the distance, direction and elapsed time since the first touch. Generate the swipe speed based on the calculation results.

I’ve got some code that I’ll post once I’m home in a few hours.


Not sure if it’s the most efficient way to do this, but it works for the game I’ve got going at the minute. Here are a couple of screenshots of what I coded (note, the last line at the bottom of the first image is repeated at the top of the second):


Wow, amazing !!!
I don’t understand what is touchID. It is a system variable or I have to manage it ?

Heh, the give away is in the action itself - Change the global variable TouchId.

You’ll have to define all the variables referenced in the code. I mixed and matched the type - global or scene. Ideally they’d all be one or the other. But you get the idea of how it should work.

Thanks for the information. But i dont get it working. There is nothing happening with a swipe. And i dont know what is wrong about it. This is what i got now.

Events :

Variable :

Preview :

The only thing i want is swiping right. So i figured out that the y axis or angle doesn’t have to be in these events. And i could’nt find a bounce action, where do i find this?

This is what i want :

  • In the start of the scene the boat (kano) should not move.
  • If there is a swipe to the right the boat moves to the pink square (invisebel), if the boat is in collision with the pink square the boat should move the the black square and stops there.
  • If the boat moves. You can’t swipe it. Boat is not moving, then swipe again. And repeat that 6 times to reach the goal.

Thanks for your help!

Play around with TouchSensitivity - I’ve set mine to 30. Larger values mean the swipe needs to be faster. Lower values make it sensitive to smaller touch movements.

That still doesnt work.

Ok, so debug it to work out what is going on.

Debugging isn’t that easy with GDevelop, but one [old skool] trick I use is to have a text box on the screen, and output variable values to it in the action of an event I’d expect to fire. This then tells you if a certain event is meeting the conditions, and you can check whether the values are what you’d expect.