We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2c41814 commit 9757d83Copy full SHA for 9757d83
1 file changed
v2-community/src/geom/Point.js
@@ -374,6 +374,24 @@ Phaser.Point.prototype = {
374
375
},
376
377
+ /**
378
+ * Alters the Point object so it's magnitude is at most the max value.
379
+ *
380
+ * @method Phaser.Point#limit
381
+ * @param {number} max - The maximum magnitude for the Point.
382
+ * @return {Phaser.Point} This Point object.
383
+ */
384
+ limit: function (max) {
385
+
386
+ if (this.getMagnitudeSq() > max * max)
387
+ {
388
+ this.setMagnitude(max);
389
+ }
390
391
+ return this;
392
393
+ },
394
395
/**
396
* Determine if this point is at 0,0.
397
*
0 commit comments