mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 13:43:26 +00:00
Added support for GetRandomPoint to the Curve and Path classes.
This commit is contained in:
parent
6a3280bd34
commit
f40459553d
4 changed files with 42 additions and 0 deletions
|
@ -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'),
|
||||
|
|
20
v3/src/curves/curve/inc/GetRandomPoint.js
Normal file
20
v3/src/curves/curve/inc/GetRandomPoint.js
Normal 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;
|
|
@ -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'),
|
||||
|
|
20
v3/src/curves/path/inc/GetRandomPoint.js
Normal file
20
v3/src/curves/path/inc/GetRandomPoint.js
Normal 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;
|
Loading…
Reference in a new issue