Continuous right click plot#11
Conversation
…the right mouse button is held down
| input.moveCallbacks[i].callback.call(input.moveCallbacks[i].context, this, this.x, this.y, fromClick); | ||
| } | ||
|
|
||
| input.interactiveItems.callAll('_pointerMoveHandler', this); |
There was a problem hiding this comment.
We don't actually need to call move on all the interactive objects, that's more for click down and up events (like draggin)
| } | ||
| }, | ||
|
|
||
| _pointerMoveHandler: function(pointer) { |
There was a problem hiding this comment.
Take a look at src/client/objects/sector/Movement.js - an old version of how to detect mouse movement without events is commented out...
You probably don't need to edit InputHandler.js
| this.world.removeListener('inputMove', this._onInputMove); | ||
|
|
||
| this.game = | ||
| this.input = undefined; |
There was a problem hiding this comment.
See:
Movement.prototype.move = function() {
...
You could probably do something similar here, in fact, that is what that function use to do, but it needs to be fixed and updated.
| this.fireEmitter = new FireEmitter(this.game); | ||
|
|
||
| // throttled function to plot ship course | ||
| this._throttledPlot = null; |
There was a problem hiding this comment.
You can throttle using
this.game.clock.throttle(this.move, 100, this);
|
Lets Skype about the problem:
|
I could not find any handler code tied to mouse move events in Pointer, so I added a new handler for it. I'm not 100% sure it should be like this, please check. (InputHandler / Pointer code).
The other parts of the code I consider solid (given there is an 'inputMove' event) It became slightly more complicated than before to be able to handle situations when both buttons are pressed / held.
The throttle threshold is set to 250 ms (hardcoded), is that ok?
Please note that handling button presses is done through _touchedHandler() in InputHandler, (original code, not my additions) which does not work with multiple button presses: it will only dispatch an 'inputDown' on the first press, after that data.isDown is true (obviously) and so in case of holding one mouse button and pressing another one, the second press is not registered and the primary/secondary action is not triggered. Since this is an existing behavior/limitation in the input handling code, I did not want to change it (also "_touchedHandler" implies touch control handling, which cannot have multiple buttons) and considered it separate from this feature.