Listen for TOUCH_END on a Cocos Creator node, measure the interval between two events, and trigger double-click behavior with a configurable threshold.
The following component detects a double click by measuring the interval between two TOUCH_END events:
if (currentTime - this.lastClickTime <= this.doubleClickInterval) { console.log('Double click!'); // Run the double-click action here. }
this.lastClickTime = currentTime; } }
doubleClickInterval is the maximum time, in milliseconds, allowed between the two clicks. Adjust it to suit the interaction. Removing the listener in onDestroy prevents a stale callback from remaining after the component is destroyed.