Jump to content

Button Double-Click


johncintron
 Share

Recommended Posts

Phaser buttons don't have a built-in double-click handler so I created one because all of the other solutions I've seen are long and convoluted and hackily target the Input class rather than Button instances.

var delay = 300;

var button = game.add.button(x, y, key, function() {
    // code for first click
    let now = Date.now();
    now - this.lastClick <= delay && this.onDoubleClick();
    this.lastClick = now;
});

button.lastClick = 0;
button.onDoubleClick = function() {
    // code for double click
}

Thoughts?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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