Skip to content

Continuous right click plot#11

Open
nkrisztian89 wants to merge 2 commits into
developfrom
continuous-right-click-plot
Open

Continuous right click plot#11
nkrisztian89 wants to merge 2 commits into
developfrom
continuous-right-click-plot

Conversation

@nkrisztian89
Copy link
Copy Markdown

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.

input.moveCallbacks[i].callback.call(input.moveCallbacks[i].context, this, this.x, this.y, fromClick);
}

input.interactiveItems.callAll('_pointerMoveHandler', this);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can throttle using
this.game.clock.throttle(this.move, 100, this);

@neutrino84
Copy link
Copy Markdown
Owner

Lets Skype about the problem:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants