Skip to content

Commit 3cc17f5

Browse files
committed
The RandomDataGenerator will now create a default random seed if you instantiate your own version of the class (instead of using Phaser.Math.RND) and don't provide a seed for it
1 parent 8d1caff commit 3cc17f5

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ The Tile Sprite Game Object has been given an internal overhaul to make it more
147147
* The `changedata` event dispatched by the Data Manager now includes the previous value as the 4th argument to the callback, so the event signature is now: `parent, key, value, previousValue` (thanks @iamchristopher)
148148
* The call to `gl.clearColor` is now skipped when `clearBeforeRender` is set to `false` (thanks @goldfire)
149149
* The calls to `DistanceBetween` have been replaced with `DistanceSquared` in the `closest` and `furthest` functions within Arcade Physics (thanks @Mursaat)
150+
* The RandomDataGenerator will now create a default random seed if you instantiate your own version of the class (instead of using `Phaser.Math.RND`) and don't provide a seed for it (thanks michaeld)
150151

151152
### Game Config Resolution Specific Bug Fixes
152153

src/math/random-data-generator/RandomDataGenerator.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,27 @@ var Class = require('../../utils/Class');
1313
* Access via `Phaser.Math.RND` which is an instance of this class pre-defined
1414
* by Phaser. Or, create your own instance to use as you require.
1515
*
16-
* The generator is seeded by the Game Config property value `seed`.
16+
* The `Math.RND` generator is seeded by the Game Config property value `seed`.
1717
* If no such config property exists, a random number is used.
18+
*
19+
* If you create your own instance of this class you should provide a seed for it.
20+
* If no seed is given it will use a 'random' one based on Date.now.
1821
*
1922
* @class RandomDataGenerator
2023
* @memberOf Phaser.Math
2124
* @constructor
2225
* @since 3.0.0
2326
*
24-
* @param {string[]} [seeds] - The seeds.
27+
* @param {(string|string[])} [seeds] - The seeds to use for the random number generator.
2528
*/
2629
var RandomDataGenerator = new Class({
2730

2831
initialize:
2932

3033
function RandomDataGenerator (seeds)
3134
{
35+
if (seeds === undefined) { seeds = [ (Date.now() * Math.random()).toString() ]; }
36+
3237
/**
3338
* Internal var.
3439
*

0 commit comments

Comments
 (0)