Skip to content

Commit f404595

Browse files
committed
Added support for GetRandomPoint to the Curve and Path classes.
1 parent 6a3280b commit f404595

4 files changed

Lines changed: 42 additions & 0 deletions

File tree

v3/src/curves/curve/Curve.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ var Curve = new Class({
9393
getLengths: require('./inc/GetLengths'),
9494
getPointAt: require('./inc/GetPointAt'),
9595
getPoints: require('./inc/GetPoints'),
96+
getRandomPoint: require('./inc/GetRandomPoint'),
9697
getSpacedPoints: require('./inc/GetSpacedPoints'),
9798
getStartPoint: require('./inc/GetStartPoint'),
9899
getTangent: require('./inc/GetTangent'),
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var Vector2 = require('../../../math/Vector2');
2+
3+
/**
4+
* [description]
5+
*
6+
* @method Phaser.Curves.Curve#getRandomPoint
7+
* @since 3.0.0
8+
*
9+
* @param {Phaser.Math.Vector2} [out] - [description]
10+
*
11+
* @return {Phaser.Math.Vector2} [description]
12+
*/
13+
var GetRandomPoint = function (out)
14+
{
15+
if (out === undefined) { out = new Vector2(); }
16+
17+
return this.getPoint(Math.random(), out);
18+
};
19+
20+
module.exports = GetRandomPoint;

v3/src/curves/path/Path.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ var Path = new Class({
5151
getLength: require('./inc/GetLength'),
5252
getPoint: require('./inc/GetPoint'),
5353
getPoints: require('./inc/GetPoints'),
54+
getRandomPoint: require('./inc/GetRandomPoint'),
5455
getSpacedPoints: require('./inc/GetSpacedPoints'),
5556
getStartPoint: require('./inc/GetStartPoint'),
5657
lineTo: require('./inc/LineTo'),
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var Vector2 = require('../../../math/Vector2');
2+
3+
/**
4+
* [description]
5+
*
6+
* @method Phaser.Curves.Path#getRandomPoint
7+
* @since 3.0.0
8+
*
9+
* @param {Phaser.Math.Vector2} [out] - [description]
10+
*
11+
* @return {Phaser.Math.Vector2} [description]
12+
*/
13+
var GetRandomPoint = function (out)
14+
{
15+
if (out === undefined) { out = new Vector2(); }
16+
17+
return this.getPoint(Math.random(), out);
18+
};
19+
20+
module.exports = GetRandomPoint;

0 commit comments

Comments
 (0)