markjsb Posted April 30, 2014 Share Posted April 30, 2014 I've seen that there is a double tap rate that can be set, but does anyone know how to read this? Thanks Link to comment Share on other sites More sharing options...
Cryptonomicon Posted May 16, 2014 Share Posted May 16, 2014 No but I have the same question Link to comment Share on other sites More sharing options...
Heppell08 Posted May 16, 2014 Share Posted May 16, 2014 I think you'd need to use justPressed() So I think it would be:if(Tapped.justPressed(0) && Tapped.justPressed(1)) { // double tap code } Link to comment Share on other sites More sharing options...
Cryptonomicon Posted May 17, 2014 Share Posted May 17, 2014 I've ended up with the idea of starting a small timer on the first tap and if a second is not received within a given time then calling a single tap callback otherwise calling a double tap callback. The problem is that if you don't wait to see if there is a second that every double tap also being classed as a single. In my case it is single tap to move to a position double tap to attack a position - which would have had the effect moving squishies to melee range on every attack. wooops. haven't written it yet so no example code. Link to comment Share on other sites More sharing options...
jpdev Posted May 17, 2014 Share Posted May 17, 2014 But that is a problem that will never really go away.You can't know if another tap is coming or not. The same applies to click and double-click. Windows for example uses a defined amount of time (which you can change in the mouse settings) between clicks to determine if it's two single clicks or a double click. Btw: you do not need to start any timer, you just create a variable in which you store game.time.now - and then on the second click you compare game.time.now to the content of that variable. (the difference is the time between the clicks) Workaround:You could start a timer on single click (that fires shortly after the double-tap-amount-of-time) and kill that timer if the second tap comes in time. This way you have either a (slightly delayed) single tap event, or the double tap event. Link to comment Share on other sites More sharing options...
Heppell08 Posted May 17, 2014 Share Posted May 17, 2014 Yeah it seems a timer is going to be the only real option. Just go with jpdev's advice on the game.time.now variable to compare the times on taps. Link to comment Share on other sites More sharing options...
lokhmakov Posted May 21, 2014 Share Posted May 21, 2014 Typescript example: dClickLast: number; isDoubleClick(o_pointer: Phaser.Pointer) : boolean { if (o_pointer.justReleased(30)) { var now = new Date().getTime(); var timesince = now - this.dClickLast; if((timesince < 600) && (timesince > 0)) { return true; } this.dClickLast = new Date().getTime(); } return false; } Link to comment Share on other sites More sharing options...
alpertayfun Posted June 8, 2015 Share Posted June 8, 2015 This is my solution :var mylatesttap; sprite.events.onInputDown.add(doubleclick,this); function doubleclick(item,pointer){ var now = new Date().getTime(); var timesince = now - mylatesttap; if((timesince < 600) && (timesince > 0)){ console.log("double tap"); }else{ console.log("don't"); } mylatesttap = new Date().getTime();} Link to comment Share on other sites More sharing options...
ericthelawrence Posted September 21, 2016 Share Posted September 21, 2016 Of note, here's a solution for double tapping on a specific sprite var tapHandler = function(sprite, pointer) { if (pointer.msSinceLastClick < game.input.doubleTapRate) { console.log('Double clicked sprite: ', sprite.key); } }; // var create = function(game) { // Create sprite var myFancySprite = game.add.sprite(10, 10, 'fancyspritekey'); // enable input myFancySprite.inputEnabled = true; // add event listener myFancySprite.events.onInputDown.add(tapHandler, this); }; Link to comment Share on other sites More sharing options...
samme Posted September 21, 2016 Share Posted September 21, 2016 The first argument to the input.onTap callback indicates double (true) or single (false). Link to comment Share on other sites More sharing options...
Recommended Posts