I'm using Cocos2d-JS and need to find a way to listen for a mouse button hold. It seems limited in that there's only onMousemove, onMouseDown, and onMouseUp. All of those only get fired once. How do I use them to detect when a mouse button is being held down? I can't just use onMouseDown since that's being used to perform an action if the button is clicked.
I can suggest the following solution for this. You can have a counter.
onMouseDownwill launch a method that will increment the counter viasetIntervaland check whether the counter reached the target value. If the value is reached, it will trigger whatever you want to be triggered by mouse button hold.onMouseUpwill wipe off the interval counter. Here is the simplified code. Assuming these to be methods of an object.