How would I go about finding the dx/dy for a touch move event?

So with the mouse move function you can get a variable dx/dy which measures the distance of the last few mouse positions (at least that’s what I assume)

There is no dx/dy that I can see for a touch move and was curious what way I could get the same results that you’d get from the mouse move.

I tried this idea in pseudo code:

var firstPositionX = 0;
var lastPositionX = 0;

var hasXpositionChanged = false;

  firstPositionX = touch.x;
  hasXpositionChanged = false;

} else {
  lastPositionX = firstPositionX;
  hasXpositionChanged = true;

var distanceX = firstPositionX - lastPositionX;

My code could be broke but it would show a varying amount of distance created, but it doesn’t seem to be the right fit. Not sure why.

subtract the last position from current position to get the delta

1 Like

I’ll try it out when I get home

To add to that, you store the last location of all the current touch IDs (by a dictionary/array) that gets updated on touch down and touch move events.

Yea that may be something I’ll look into.

I have a working solution now so thanks.