Skip to content

Commit 2b8426a

Browse files
committed
Fixed data passing.
1 parent 1e17678 commit 2b8426a

5 files changed

Lines changed: 24 additions & 37 deletions

File tree

v3/src/boot/Game.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ var DebugHeader = require('./DebugHeader');
99
var Device = require('../device');
1010

1111
var AddToDOM = require('../dom/AddToDOM');
12-
// var RequestAnimationFrame = require('../dom/RequestAnimationFrame');
1312
var DOMContentLoaded = require('../dom/DOMContentLoaded');
1413

1514
var MainLoop = require('./MainLoop');
@@ -30,12 +29,6 @@ var Game = function (config)
3029
this.isBooted = false;
3130
this.isRunning = false;
3231

33-
/**
34-
* @property {Phaser.RequestAnimationFrame} raf - Automatically handles the core game loop via requestAnimationFrame or setTimeout
35-
* @protected
36-
*/
37-
// this.raf = new RequestAnimationFrame();
38-
3932
/**
4033
* @property {Phaser.TextureManager} textures - Reference to the Phaser Texture Manager.
4134
*/
@@ -102,18 +95,8 @@ Game.prototype = {
10295
this.config.postBoot();
10396

10497
this.mainloop.start();
105-
106-
// this.raf.start(this.step.bind(this), this.config.forceSetTimeOut);
10798
}
10899

109-
/*
110-
step: function (timestamp)
111-
{
112-
// Pass in via game to 'start' instead of every update?
113-
this.mainloop.step(timestamp, this.state.active, this.renderer);
114-
}
115-
*/
116-
117100
};
118101

119102
module.exports = Game;

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: 'f6d064e0-f4b1-11e6-981a-5d27875bf1f1'
2+
build: '80ede0f0-f4b5-11e6-bebe-efbf3f13a534'
33
};
44
module.exports = CHECKSUM;

v3/src/state/GlobalStateManager.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ GlobalStateManager.prototype = {
359359
if (data === undefined) { data = {}; }
360360

361361
// console.log('start:', key);
362+
// console.dir(data);
362363

363364
// if not booted, then put state into a holding pattern
364365
if (!this.game.isBooted)
@@ -391,6 +392,8 @@ GlobalStateManager.prototype = {
391392

392393
state.settings.active = true;
393394

395+
state.settings.data = data;
396+
394397
var loader = state.sys.load;
395398

396399
// Files payload?
@@ -400,39 +403,38 @@ GlobalStateManager.prototype = {
400403

401404
if (loader.loadArray(state.sys.settings.files))
402405
{
403-
loader.events.once('LOADER_COMPLETE_EVENT', this.payloadComplete.bind(this, data));
406+
loader.events.once('LOADER_COMPLETE_EVENT', this.payloadComplete.bind(this));
404407

405408
loader.start();
406409
}
407410
else
408411
{
409-
this.bootState(state, data);
412+
this.bootState(state);
410413
}
411414
}
412415
else
413416
{
414-
this.bootState(state, data);
417+
this.bootState(state);
415418
}
416419
}
417420
},
418421

419-
payloadComplete: function (event, data)
422+
payloadComplete: function (event)
420423
{
421424
var state = event.loader.state;
422425

423426
// console.log('payloadComplete', state.sys.settings.key);
424427

425-
this.bootState(state, data);
428+
this.bootState(state);
426429
},
427430

428-
bootState: function (state, data)
431+
bootState: function (state)
429432
{
430-
console.log('bootState', state.sys.settings.key);
431-
console.dir(data);
433+
// console.log('bootState', state.sys.settings.key);
432434

433435
if (state.init)
434436
{
435-
state.init.call(state, data);
437+
state.init.call(state, state.sys.settings.data);
436438
}
437439

438440
var loader = state.sys.load;
@@ -446,36 +448,36 @@ GlobalStateManager.prototype = {
446448
// Is the loader empty?
447449
if (loader.list.size === 0)
448450
{
449-
this.create(state, data);
451+
this.create(state);
450452
}
451453
else
452454
{
453455
// Start the loader going as we have something in the queue
454456

455-
loader.events.once('LOADER_COMPLETE_EVENT', this.loadComplete.bind(this, {}, data));
457+
loader.events.once('LOADER_COMPLETE_EVENT', this.loadComplete.bind(this));
456458

457459
loader.start();
458460
}
459461
}
460462
else
461463
{
462464
// No preload? Then there was nothing to load either
463-
this.create(state, data);
465+
this.create(state);
464466
}
465467
},
466468

467-
loadComplete: function (event, data)
469+
loadComplete: function (event)
468470
{
469471
var state = event.loader.state;
470472

471473
// console.log('loadComplete', state.sys.settings.key);
472474

473-
this.create(state, data);
475+
this.create(state);
474476
},
475477

476-
create: function (state, data)
478+
create: function (state)
477479
{
478-
console.log('create', state.sys.settings.key);
480+
// console.log('create', state.sys.settings.key);
479481

480482
// Insert at the correct index, or it just all goes wrong :)
481483

@@ -492,7 +494,7 @@ GlobalStateManager.prototype = {
492494

493495
if (state.create)
494496
{
495-
state.create(data);
497+
state.create(state.sys.settings.data);
496498
}
497499
},
498500

v3/src/state/Settings.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ var Settings = {
2828

2929
// Loader payload array
3030

31+
data: {},
32+
3133
files: GetObjectValue(config, 'files', false),
3234

3335
// -1 means the State Manager will set it to be the Game dimensions

v3/src/state/systems/StateManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ StateManager.prototype.constructor = StateManager;
1616
StateManager.prototype = {
1717

1818
// Start this State (or the one given via key)
19-
start: function (key)
19+
start: function (key, data)
2020
{
2121
if (key === undefined) { key = this.key; }
2222

23-
this.manager.start(key);
23+
this.manager.start(key, data);
2424
},
2525

2626
// Pause this State (or the one given via key)

0 commit comments

Comments
 (0)