Merge pull request #2927 from nickaversano/master

add limit method on Phaser.Point
This commit is contained in:
Richard Davey 2016-12-21 14:28:18 +00:00 committed by GitHub
commit 4dd2f9a93e

View file

@ -374,6 +374,24 @@ Phaser.Point.prototype = {
},
/**
* Alters the Point object so it's magnitude is at most the max value.
*
* @method Phaser.Point#limit
* @param {number} max - The maximum magnitude for the Point.
* @return {Phaser.Point} This Point object.
*/
limit: function (max) {
if (this.getMagnitudeSq() > max * max)
{
this.setMagnitude(max);
}
return this;
},
/**
* Determine if this point is at 0,0.
*