diff --git a/v3/src/curves/curve/Curve.js b/v3/src/curves/curve/Curve.js index 9a61785be..3be412d2f 100644 --- a/v3/src/curves/curve/Curve.js +++ b/v3/src/curves/curve/Curve.js @@ -93,6 +93,7 @@ var Curve = new Class({ getLengths: require('./inc/GetLengths'), getPointAt: require('./inc/GetPointAt'), getPoints: require('./inc/GetPoints'), + getRandomPoint: require('./inc/GetRandomPoint'), getSpacedPoints: require('./inc/GetSpacedPoints'), getStartPoint: require('./inc/GetStartPoint'), getTangent: require('./inc/GetTangent'), diff --git a/v3/src/curves/curve/inc/GetRandomPoint.js b/v3/src/curves/curve/inc/GetRandomPoint.js new file mode 100644 index 000000000..d608b2561 --- /dev/null +++ b/v3/src/curves/curve/inc/GetRandomPoint.js @@ -0,0 +1,20 @@ +var Vector2 = require('../../../math/Vector2'); + +/** + * [description] + * + * @method Phaser.Curves.Curve#getRandomPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ +var GetRandomPoint = function (out) +{ + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(Math.random(), out); +}; + +module.exports = GetRandomPoint; diff --git a/v3/src/curves/path/Path.js b/v3/src/curves/path/Path.js index 2493aa67d..c41651300 100644 --- a/v3/src/curves/path/Path.js +++ b/v3/src/curves/path/Path.js @@ -51,6 +51,7 @@ var Path = new Class({ getLength: require('./inc/GetLength'), getPoint: require('./inc/GetPoint'), getPoints: require('./inc/GetPoints'), + getRandomPoint: require('./inc/GetRandomPoint'), getSpacedPoints: require('./inc/GetSpacedPoints'), getStartPoint: require('./inc/GetStartPoint'), lineTo: require('./inc/LineTo'), diff --git a/v3/src/curves/path/inc/GetRandomPoint.js b/v3/src/curves/path/inc/GetRandomPoint.js new file mode 100644 index 000000000..5fcf1a6b5 --- /dev/null +++ b/v3/src/curves/path/inc/GetRandomPoint.js @@ -0,0 +1,20 @@ +var Vector2 = require('../../../math/Vector2'); + +/** + * [description] + * + * @method Phaser.Curves.Path#getRandomPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ +var GetRandomPoint = function (out) +{ + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(Math.random(), out); +}; + +module.exports = GetRandomPoint;