Skip to content

Commit d276271

Browse files
committed
RandomDataGenerator is now started on Game creation instead of boot. You can pass a seed array in the game config object (feature request phaserjs#547)
1 parent e6d520f commit d276271

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ Significant API changes:
9090
* Sprite.damage will now kill the Sprite if health is less than or equal to 0 (before it would only kill if less than zero)
9191
* By default Sprites no longer check if they are within the world bounds. It's quite an expensive process (calling getBounds every frame), so you have to enable directly.
9292
* The main Game class has been modified so that the update methods no longer have any if/else checks in them. Now split into coreUpdate, etc.
93+
* RandomDataGenerator is now started on Game creation instead of boot. You can pass a seed array in the game config object (feature request #547)
9394

9495

9596
New features:

src/core/Game.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
284284
this.antialias = antialias;
285285
}
286286

287+
this.rnd = new Phaser.RandomDataGenerator([(Date.now() * Math.random()).toString()]);
288+
287289
this.state = new Phaser.StateManager(this, state);
288290
}
289291

@@ -355,6 +357,11 @@ Phaser.Game.prototype = {
355357
this.physicsConfig = config['physicsConfig'];
356358
}
357359

360+
if (config['seed'])
361+
{
362+
this.rnd = new Phaser.RandomDataGenerator(config['seed']);
363+
}
364+
358365
var state = null;
359366

360367
if (config['state'])
@@ -396,7 +403,6 @@ Phaser.Game.prototype = {
396403

397404
this.device = new Phaser.Device(this);
398405
this.math = Phaser.Math;
399-
this.rnd = new Phaser.RandomDataGenerator([(Date.now() * Math.random()).toString()]);
400406

401407
this.stage = new Phaser.Stage(this, this.width, this.height);
402408
this.scale = new Phaser.ScaleManager(this, this.width, this.height);

0 commit comments

Comments
 (0)