arkaghosh024 Posted April 19, 2018 Share Posted April 19, 2018 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 More sharing options...
samme Posted April 19, 2018 Share Posted April 19, 2018 That's a Phaser 2 example, so it won't work. I don't see any Phaser 3 examples with double-tap yet. Link to comment Share on other sites More sharing options...
arkaghosh024 Posted April 20, 2018 Author Share Posted April 20, 2018 10 hours ago, samme said: That's a Phaser 2 example, so it won't work. I don't see any Phaser 3 examples with double-tap yet. Thanks samme. Link to comment Share on other sites More sharing options...
therealjawss Posted July 29, 2018 Share Posted July 29, 2018 is there an equivalent to onTap? i know of isDown, but i want to detect if the player tapped at a specific point in time rather than touch and hold till that point... Link to comment Share on other sites More sharing options...
Recommended Posts