Warning: The magic method EDD_Blocks::__wakeup() must have public visibility in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php on line 101

Warning: The magic method EDD_Blocks::__wakeup() must have public visibility in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks/edd-blocks.php on line 101

Warning: The magic method GAINWP_Manager::__wakeup() must have public visibility in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/gainwp.php on line 78

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/tools/gapi.php on line 555

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/tools/gapi.php on line 585

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/tools/gapi.php on line 617

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/tools/gapi.php on line 651

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/tools/gapi.php on line 686

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/tools/gapi.php on line 745

Deprecated: Optional parameter $filter declared before required parameter $metric is implicitly treated as a required parameter in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/ga-in/tools/gapi.php on line 785

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/wcc1969/public_html/phasergames.com/wp-content/plugins/edd-blocks-master/edd-blocks.php:101) in /home/wcc1969/public_html/phasergames.com/wp-includes/rest-api/class-wp-rest-server.php on line 1831
{"id":16675,"date":"2020-03-26T09:40:51","date_gmt":"2020-03-26T02:40:51","guid":{"rendered":"https:\/\/phasergames.com\/?p=16675"},"modified":"2020-03-26T09:43:58","modified_gmt":"2020-03-26T02:43:58","slug":"how-to-double-click-in-phaser-3","status":"publish","type":"post","link":"https:\/\/phasergames.com\/how-to-double-click-in-phaser-3\/","title":{"rendered":"How to Double Click in Phaser 3"},"content":{"rendered":"\n

One of the things missing from a lot of modern frameworks is the ability to detect a double click. When you come down to it, a double click is simply 2 single clicks close together. All we really need to do is measure the time between clicks. We can do that by measuring the delta time<\/a>.<\/p>\n\n\n\n

class SceneMain extends Phaser.Scene {\n    constructor() {\n        super('SceneMain');\n    }\n    preload() {}\n    create() {\n        this.firstClickTime = 0;\n        \/\/add a listeners for when the pointer goes down\n        this.input.on('pointerdown', this.onDown.bind(this));\n    }\n    getTime() {\n        \/\/make a new date object\n        let d = new Date();\n        \/\/return the number of milliseconds since 1 January 1970 00:00:00.\n        return d.getTime();\n    }\n    onDown() {\n        \/\/if the firstClickTime is 0 then\n        \/\/this we record the time and leave the function\n        if (this.firstClickTime == 0) {\n            this.firstClickTime = this.getTime();\n            return;\n        }\n        \/\/\n        \/\/get the elapsed time between clicks\n        \/\/\n        let elapsed = this.getTime() - this.firstClickTime;\n        \/\/\n        \/\/if the time between clicks is less than 350 milliseconds\n        \/\/it is a doulble click\n        \/\/\n        if (elapsed < 350) {\n            console.log(\"double click\");\n        }\n        \/\/\n        \/\/reset the firstClickTime\n        \/\/\n        this.firstClickTime = 0;\n    }\n    update() {}\n}<\/code><\/pre>\n\n\n\n
\"\"<\/figure>\n\n\n\t
\n\n\t\t\n\t\t
\n\t\t\t