mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
add limit function to Point
This commit is contained in:
parent
2c41814496
commit
9757d8341d
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