How to implement double tapping?

Hi!

Well, this is my first post here, so hello everyone!

Ok, to the point. Right now I am creating an endless runner game and I’m trying to implement double-tapping. To be more clear:

  1. The Player touches the screen for a short while -> the character jumps as long as the Player is touching the screen (to a maximum degree, obviously :smile:) - this I have already implemented thanks to the Getting started tutorial.
  2. The Player double taps the screen -> the gravity is “reversed”, in a way.

I’ve searched the forum for similar issues but couldn’t find anything like that or similar. I have also already implemented reversing/inversing the gravity but I have a huuuge problem when it comes to implementing the double tap.

I’ve tried action.repeated (and by the way learnt how it really works :smiley:) and even nesting action.pressed in a condition that contains action.released but id doesn’t seem to work. My guess is that those actions would have to happen really quickly, and I mean really quickly - in the same frame which is, well, next to impossible.

So, could you please help me out with this one? I’de be more than grateful! Thanks for your help in advance!

Lucas

I implemented a gesture detector module that can be used to correctly identify gestures such as swipe-left/right, tap, long press and double tap. Take a look here: https://github.com/britzl/ludobits/blob/master/ludobits/m/gesture.lua Perhaps you can use it as inspiration for your own project?

7 Likes

This is great! Thank you so much!

FYI it’s a been a while but this link is broken…

Some quick research in that repo reveals that the code was moved to https://github.com/britzl/defold-input

2 Likes

I did do that I just hadn’t wanted to paste anything and have it not be exactly what @Britzl wanted for others to see.

Correct, my gesture detection module was moved to a separate project with a bunch of other input related modules: