Skip to content

Commit 07a55e5

Browse files
committed
Removed debug call and merged Scene Systems boot and start sequences. Fix phaserjs#3579
1 parent 1eff0b2 commit 07a55e5

12 files changed

Lines changed: 178 additions & 49 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Change Log
22

3+
## Version 3.5.1 - Kirito - in development
4+
5+
### Updates
6+
7+
* The change made in 3.5.0 with how the Scene systems lifecycle is handled has been tweaked. When a Scene is instantiated it will now emit a boot event, as before, and Systems that need it will listen for this event and set-up their internal properties as required. They'll also do the same under the 'start' event, allowing them to restart properly once shutdown. In 3.5 if a Scene was previously not launched or started you wouldn't be able to access all of its internal systems fully, but in 3.5.1 you can.
8+
9+
### Bug Fixes
10+
11+
* LoaderPlugin.destroy would try and remove an incorrect event listener.
12+
13+
314
## Version 3.5.0 - Kirito - 16th April 2018
415

516
### Changes to Cameras

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "phaser",
3-
"version": "3.5.0",
3+
"version": "3.5.1",
44
"release": "Kirito",
55
"description": "A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.",
66
"author": "Richard Davey <rich@photonstorm.com> (http://www.photonstorm.com)",

src/cameras/2d/CameraManager.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,19 @@ var CameraManager = new Class({
113113
*/
114114
this.baseScale = 1;
115115

116+
scene.sys.events.once('boot', this.boot, this);
116117
scene.sys.events.on('start', this.start, this);
117118
},
118119

119120
/**
120-
* This method is called automatically by the Scene when it is starting up.
121-
* It is responsible for creating local systems, properties and listening for Scene events.
121+
* This method is called automatically, only once, when the Scene is first created.
122122
* Do not invoke it directly.
123123
*
124-
* @method Phaser.Cameras.Scene2D.CameraManager#start
124+
* @method Phaser.Cameras.Scene2D.CameraManager#boot
125125
* @private
126-
* @since 3.5.0
126+
* @since 3.5.1
127127
*/
128-
start: function ()
128+
boot: function ()
129129
{
130130
var sys = this.systems;
131131

@@ -141,8 +141,25 @@ var CameraManager = new Class({
141141
}
142142

143143
this.main = this.cameras[0];
144+
},
144145

145-
var eventEmitter = sys.events;
146+
/**
147+
* This method is called automatically by the Scene when it is starting up.
148+
* It is responsible for creating local systems, properties and listening for Scene events.
149+
* Do not invoke it directly.
150+
*
151+
* @method Phaser.Cameras.Scene2D.CameraManager#start
152+
* @private
153+
* @since 3.5.0
154+
*/
155+
start: function ()
156+
{
157+
if (!this.main)
158+
{
159+
this.boot();
160+
}
161+
162+
var eventEmitter = this.systems.events;
146163

147164
eventEmitter.on('update', this.update, this);
148165
eventEmitter.once('shutdown', this.shutdown, this);

src/const.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var CONST = {
2020
* @type {string}
2121
* @since 3.0.0
2222
*/
23-
VERSION: '3.5.0-beta',
23+
VERSION: '3.5.1',
2424

2525
BlendModes: require('./renderer/BlendModes'),
2626

src/data/DataManagerPlugin.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,23 @@ var DataManagerPlugin = new Class({
5050
*/
5151
this.systems = scene.sys;
5252

53+
scene.sys.events.once('boot', this.boot, this);
5354
scene.sys.events.on('start', this.start, this);
5455
},
5556

57+
/**
58+
* This method is called automatically, only once, when the Scene is first created.
59+
* Do not invoke it directly.
60+
*
61+
* @method Phaser.Data.DataManagerPlugin#boot
62+
* @private
63+
* @since 3.5.1
64+
*/
65+
boot: function ()
66+
{
67+
this.events = this.systems.events;
68+
},
69+
5670
/**
5771
* This method is called automatically by the Scene when it is starting up.
5872
* It is responsible for creating local systems, properties and listening for Scene events.

src/gameobjects/GameObjectCreator.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,24 @@ var GameObjectCreator = new Class({
6969
*/
7070
this.updateList;
7171

72+
scene.sys.events.once('boot', this.boot, this);
7273
scene.sys.events.on('start', this.start, this);
7374
},
7475

76+
/**
77+
* This method is called automatically, only once, when the Scene is first created.
78+
* Do not invoke it directly.
79+
*
80+
* @method Phaser.GameObjects.GameObjectCreator#boot
81+
* @private
82+
* @since 3.5.1
83+
*/
84+
boot: function ()
85+
{
86+
this.displayList = this.systems.displayList;
87+
this.updateList = this.systems.updateList;
88+
},
89+
7590
/**
7691
* This method is called automatically by the Scene when it is starting up.
7792
* It is responsible for creating local systems, properties and listening for Scene events.
@@ -83,9 +98,6 @@ var GameObjectCreator = new Class({
8398
*/
8499
start: function ()
85100
{
86-
this.displayList = this.systems.displayList;
87-
this.updateList = this.systems.updateList;
88-
89101
var eventEmitter = this.systems.events;
90102

91103
eventEmitter.once('shutdown', this.shutdown, this);

src/gameobjects/GameObjectFactory.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,24 @@ var GameObjectFactory = new Class({
6868
*/
6969
this.updateList;
7070

71+
scene.sys.events.once('boot', this.boot, this);
7172
scene.sys.events.on('start', this.start, this);
7273
},
7374

75+
/**
76+
* This method is called automatically, only once, when the Scene is first created.
77+
* Do not invoke it directly.
78+
*
79+
* @method Phaser.GameObjects.GameObjectFactory#boot
80+
* @private
81+
* @since 3.5.1
82+
*/
83+
boot: function ()
84+
{
85+
this.displayList = this.systems.displayList;
86+
this.updateList = this.systems.updateList;
87+
},
88+
7489
/**
7590
* This method is called automatically by the Scene when it is starting up.
7691
* It is responsible for creating local systems, properties and listening for Scene events.
@@ -82,9 +97,6 @@ var GameObjectFactory = new Class({
8297
*/
8398
start: function ()
8499
{
85-
this.displayList = this.systems.displayList;
86-
this.updateList = this.systems.updateList;
87-
88100
var eventEmitter = this.systems.events;
89101

90102
eventEmitter.once('shutdown', this.shutdown, this);

src/input/InputPlugin.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,25 @@ var InputPlugin = new Class({
283283
*/
284284
this._validTypes = [ 'onDown', 'onUp', 'onOver', 'onOut', 'onMove', 'onDragStart', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDrop' ];
285285

286+
scene.sys.events.once('boot', this.boot, this);
286287
scene.sys.events.on('start', this.start, this);
287288
},
288289

290+
/**
291+
* This method is called automatically, only once, when the Scene is first created.
292+
* Do not invoke it directly.
293+
*
294+
* @method Phaser.Input.InputPlugin#boot
295+
* @private
296+
* @since 3.5.1
297+
*/
298+
boot: function ()
299+
{
300+
this.cameras = this.systems.cameras;
301+
302+
this.displayList = this.systems.displayList;
303+
},
304+
289305
/**
290306
* This method is called automatically by the Scene when it is starting up.
291307
* It is responsible for creating local systems, properties and listening for Scene events.
@@ -309,10 +325,6 @@ var InputPlugin = new Class({
309325
eventEmitter.once('destroy', this.destroy, this);
310326

311327
this.enabled = true;
312-
313-
this.cameras = this.systems.cameras;
314-
315-
this.displayList = this.systems.displayList;
316328
},
317329

318330
/**

src/loader/LoaderPlugin.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,19 +241,19 @@ var LoaderPlugin = new Class({
241241
*/
242242
this.state = CONST.LOADER_IDLE;
243243

244-
scene.sys.events.on('start', this.boot, this);
244+
scene.sys.events.on('start', this.pluginStart, this);
245245
},
246246

247247
/**
248248
* This method is called automatically by the Scene when it is starting up.
249249
* It is responsible for creating local systems, properties and listening for Scene events.
250250
* Do not invoke it directly.
251251
*
252-
* @method Phaser.Loader.LoaderPlugin#boot
252+
* @method Phaser.Loader.LoaderPlugin#pluginStart
253253
* @private
254-
* @since 3.0.0
254+
* @since 3.5.1
255255
*/
256-
boot: function ()
256+
pluginStart: function ()
257257
{
258258
var eventEmitter = this.systems.events;
259259

@@ -1008,7 +1008,7 @@ var LoaderPlugin = new Class({
10081008

10091009
this.state = CONST.LOADER_DESTROYED;
10101010

1011-
this.scene.sys.events.off('start', this.start, this);
1011+
this.systems.events.off('start', this.pluginStart, this);
10121012

10131013
this.list = null;
10141014
this.inflight = null;

src/physics/arcade/ArcadePhysics.js

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,24 @@ var ArcadePhysics = new Class({
7878
*/
7979
this.add;
8080

81+
scene.sys.events.once('boot', this.boot, this);
8182
scene.sys.events.on('start', this.start, this);
8283
},
8384

85+
/**
86+
* This method is called automatically, only once, when the Scene is first created.
87+
* Do not invoke it directly.
88+
*
89+
* @method Phaser.Physics.Arcade.ArcadePhysics#boot
90+
* @private
91+
* @since 3.5.1
92+
*/
93+
boot: function ()
94+
{
95+
this.world = new World(this.scene, this.config);
96+
this.add = new Factory(this.world);
97+
},
98+
8499
/**
85100
* This method is called automatically by the Scene when it is starting up.
86101
* It is responsible for creating local systems, properties and listening for Scene events.
@@ -92,8 +107,11 @@ var ArcadePhysics = new Class({
92107
*/
93108
start: function ()
94109
{
95-
this.world = new World(this.scene, this.config);
96-
this.add = new Factory(this.world);
110+
if (!this.world)
111+
{
112+
this.world = new World(this.scene, this.config);
113+
this.add = new Factory(this.world);
114+
}
97115

98116
var eventEmitter = this.systems.events;
99117

@@ -454,7 +472,11 @@ var ArcadePhysics = new Class({
454472
eventEmitter.off('postupdate', this.world.postUpdate, this.world);
455473
eventEmitter.off('shutdown', this.shutdown, this);
456474

457-
this.world.shutdown();
475+
this.add.destroy();
476+
this.world.destroy();
477+
478+
this.add = null;
479+
this.world = null;
458480
},
459481

460482
/**
@@ -468,15 +490,10 @@ var ArcadePhysics = new Class({
468490
{
469491
this.shutdown();
470492

471-
this.add.destroy();
472-
this.world.destroy();
473-
474493
this.scene.sys.events.off('start', this.start, this);
475494

476495
this.scene = null;
477496
this.systems = null;
478-
this.world = null;
479-
this.add = null;
480497
}
481498

482499
});

0 commit comments

Comments
 (0)