Added Pointer.getDistance method

This commit is contained in:
Richard Davey 2018-09-12 01:03:56 +01:00
parent e01013d418
commit 4ba3b37608

View file

@ -5,10 +5,10 @@
*/
var Class = require('../utils/Class');
var Distance = require('../math/distance/DistanceBetween');
var SmoothStepInterpolation = require('../math/interpolation/SmoothStepInterpolation');
var Vector2 = require('../math/Vector2');
/**
* @classdesc
* A Pointer object encapsulates both mouse and touch input within Phaser.
@ -662,6 +662,20 @@ var Pointer = new Class({
return (this.buttons & 16);
},
/**
* Returns the distance between the Pointer's current position and where it was
* first pressed down (the `downX` and `downY` properties)
*
* @method Phaser.Input.Pointer#getDistance
* @since 3.13.0
*
* @return {number} The distance the Pointer has moved since being pressed down.
*/
getDistance: function ()
{
return Distance(this.downX, this.downY, this.x, this.y);
},
/**
* Takes the previous and current Pointer positions and then generates an array of interpolated values between
* the two. The array will be populated up to the size of the `steps` argument.