mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 22:52:14 +00:00
Merge pull request #2927 from nickaversano/master
add limit method on Phaser.Point
This commit is contained in:
commit
4dd2f9a93e
1 changed files with 18 additions and 0 deletions
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue