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.
1
There are 1 best solutions below
Related Questions in COCOS2D-JS
- How can I correct this error in cocos2d-x
- Issue with compiling a cocos2d-x 3.17.2 JS/web project
- Cocos Creator JavaScript the callback function of cc.resources.load not work
- Cocos Typescript Error Global variable cc was dropped since 3.0. Use ES6 module syntax to import Cocos Creator APIs
- Add a function to a class defined inside a declared namespace (Typescript)
- Cocos-2dx JS can't load scene from JSON file with version 3.10.0.0
- A problem occurred configuring project ':game'. > java.lang.NullPointerException (no error message)
- How to solve nginx server restart issue?
- Create common modules between projects [COCOS2D]
- How to send final game score between Cocos Creator scenes?
- Couldn't call Objective-C method from Cocos-2d via JavaScriptObjCBridge
- cocos2d JS WebGL rendering is not working in iOS 14 public beta
- TypeError: Cannot read property 'load' of undefined at cc.resources
- cocos2d, can we call a function in "sequence" on a sprite?
- position AnchorPoint of a sprite in Cocos2d
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
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.