mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
Added Pointer.getDistance method
This commit is contained in:
parent
e01013d418
commit
4ba3b37608
1 changed files with 15 additions and 1 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue