Jump to content

Detecting doubleTap in PhaserJS


arkaghosh024
 Share

Recommended Posts

I am a complete newbie in PhaserJS. I am trying to develop a game in PhaserJS where tapping the screen once should make the user avatar move on the screen and double-tapping should make it jump. However, I am not being able to figure out how to detect the double tap event. I have seen this tutorial in their official documentation, but that didn't work. When I am putting this line

game.input.onTap.add(onTap, this);

in the

function create(){
    .....
} 

function, it is showing this error

Uncaught TypeError: Cannot read property 'add' of undefined

I am being able to detect single tap events using this code:

if(game.input.onTap && player.body.touching.down){
    player.setVelocity(-530);
}

I've read another thread where the members have commented that to detect double click, one should start a timer and check if both the clicks are coming within a threshold value. However, I think this is not a foolproof method and there must be a better way of doing it. Can anyone please help?

Link to comment
Share on other sites

  • 3 months later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...