Added support for GetRandomPoint to the Curve and Path classes.

This commit is contained in:
Richard Davey 2017-10-18 13:45:34 +01:00
parent 6a3280bd34
commit f40459553d
4 changed files with 42 additions and 0 deletions

View file

@ -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'),

View file

@ -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;

View file

@ -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'),

View file

@ -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;