britzl / defold-input

Simplify input related operations such as gesture detection, input mapping and clicking/dragging game objects
MIT License
111 stars 26 forks source link

Request: Distance from origin on drag #21

Closed Trevortni closed 1 year ago

Trevortni commented 2 years ago

I suppose this is my fault that I didn't realize this earlier, but I'm pretty sure dx and dy only give the distance traveled since the last frame. Would it be possible to get a pair of extra values representing the distance from where the mouse button was first pressed?

For that matter, just knowing where the mousedown first occurred could be useful as well, though I only really need one or the other at the moment (since having one gives you the other via math).

britzl commented 2 years ago

You should get a drag start event I think. And it should contain a starting position.

Trevortni commented 2 years ago

You should get a drag start event I think. And it should contain a starting position.

This is in the drag start event. Well, it's in the listener for the drag start event, anyway. If there's a starting position there, I don't see it.

image

britzl commented 2 years ago

Isn't the x & y values the starting position?

Trevortni commented 2 years ago

Here's dragging the same object from the same starting point the opposite direction:

image

Trevortni commented 2 years ago

I'm pretty sure x and y are the current cursor position.

britzl commented 2 years ago

Ah, true, it is not the same as the initial pressed position, but rather the position when the drag started (ie when moving the cursor above the drag threshold).