Skip to content

Commit 5b922be

Browse files
committed
Version 2.1.1. of Phaser is an emergency point release. It addresses a potential race condition that could happen in States that tried to change state from the create method but had an empty preloader or pre-cached assets.
1 parent a1a0861 commit 5b922be

22 files changed

+439
-176
lines changed

README.md

Lines changed: 175 additions & 8 deletions
Large diffs are not rendered by default.

bower.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": "2.1.0",
3+
"version": "2.1.1",
44
"homepage": "http://phaser.io",
55
"authors": [
66
"photonstorm <[email protected]>"

build/custom/ninja.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/custom/p2.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/custom/phaser-arcade-physics.js

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Phaser - http://phaser.io
99
*
10-
* v2.1.0 "Cairhien" - Built: Tue Sep 09 2014 15:35:44
10+
* v2.1.1 "Eianrod" - Built: Thu Sep 11 2014 10:37:16
1111
*
1212
* By Richard Davey http://www.photonstorm.com @photonstorm
1313
*
@@ -11382,7 +11382,7 @@ PIXI.RenderTexture.tempMatrix = new PIXI.Matrix();
1138211382
*
1138311383
* Phaser - http://phaser.io
1138411384
*
11385-
* v2.1.0 "Cairhien" - Built: Tue Sep 09 2014 15:35:44
11385+
* v2.1.1 "Eianrod" - Built: Thu Sep 11 2014 10:37:16
1138611386
*
1138711387
* By Richard Davey http://www.photonstorm.com @photonstorm
1138811388
*
@@ -11425,7 +11425,7 @@ PIXI.RenderTexture.tempMatrix = new PIXI.Matrix();
1142511425
*/
1142611426
var Phaser = Phaser || {
1142711427

11428-
VERSION: '2.1.0',
11428+
VERSION: '2.1.1',
1142911429
GAMES: [],
1143011430

1143111431
AUTO: 0,
@@ -16240,6 +16240,8 @@ Phaser.StateManager.prototype = {
1624016240

1624116241
this.setCurrentState(this._pendingState);
1624216242

16243+
this._pendingState = null;
16244+
1624316245
if (this.onPreloadCallback)
1624416246
{
1624516247
this.game.load.reset();
@@ -16261,8 +16263,6 @@ Phaser.StateManager.prototype = {
1626116263
// No init? Then there was nothing to load either
1626216264
this.loadComplete();
1626316265
}
16264-
16265-
this._pendingState = null;
1626616266
}
1626716267

1626816268
},
@@ -20772,15 +20772,20 @@ Phaser.FlexGrid.prototype = {
2077220772
* @param {array} [children] - An array of children that are used to populate the FlexLayer.
2077320773
* @return {Phaser.FlexLayer} The Layer object.
2077420774
*/
20775-
createFluidLayer: function (children) {
20775+
createFluidLayer: function (children, addToWorld) {
20776+
20777+
if (typeof addToWorld === 'undefined') { addToWorld = true; }
2077620778

2077720779
var layer = new Phaser.FlexLayer(this, this.positionFluid, this.boundsFluid, this.scaleFluid);
2077820780

20779-
this.game.world.add(layer);
20781+
if (addToWorld)
20782+
{
20783+
this.game.world.add(layer);
20784+
}
2078020785

2078120786
this.layers.push(layer);
2078220787

20783-
if (typeof children !== 'undefined')
20788+
if (typeof children !== 'undefined' && typeof children !== null)
2078420789
{
2078520790
layer.addMultiple(children);
2078620791
}
@@ -20844,15 +20849,19 @@ Phaser.FlexGrid.prototype = {
2084420849
*/
2084520850
reset: function () {
2084620851

20847-
for (var i = 0; i < this.layers.length; i++)
20852+
var i = this.layers.length;
20853+
20854+
while (i--)
2084820855
{
20849-
// Remove references to this class
20850-
this.layers[i].position = null;
20851-
this.layers[i].scale = null;
20856+
if (!this.layers[i].persist)
20857+
{
20858+
// Remove references to this class
20859+
this.layers[i].position = null;
20860+
this.layers[i].scale = null;
20861+
this.layers.slice(i, 1);
20862+
}
2085220863
}
2085320864

20854-
this.layers.length = 0;
20855-
2085620865
},
2085720866

2085820867
/**
@@ -20951,12 +20960,19 @@ Phaser.FlexLayer = function (manager, position, bounds, scale) {
2095120960
/**
2095220961
* @property {Phaser.ScaleManager} scale - A reference to the ScaleManager.
2095320962
*/
20954-
this.manager = manager;
20963+
this.manager = manager.manager;
2095520964

2095620965
/**
2095720966
* @property {Phaser.FlexGrid} grid - A reference to the FlexGrid that owns this layer.
2095820967
*/
20959-
this.grid = manager.grid;
20968+
this.grid = manager;
20969+
20970+
/**
20971+
* Should the FlexLayer remain through a State swap?
20972+
*
20973+
* @type {boolean}
20974+
*/
20975+
this.persist = false;
2096020976

2096120977
// Bound to the grid
2096220978
this.position = position;

build/custom/phaser-arcade-physics.min.js

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/custom/phaser-ninja-physics.js

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Phaser - http://phaser.io
99
*
10-
* v2.1.0 "Cairhien" - Built: Tue Sep 09 2014 15:35:44
10+
* v2.1.1 "Eianrod" - Built: Thu Sep 11 2014 10:37:16
1111
*
1212
* By Richard Davey http://www.photonstorm.com @photonstorm
1313
*
@@ -11382,7 +11382,7 @@ PIXI.RenderTexture.tempMatrix = new PIXI.Matrix();
1138211382
*
1138311383
* Phaser - http://phaser.io
1138411384
*
11385-
* v2.1.0 "Cairhien" - Built: Tue Sep 09 2014 15:35:44
11385+
* v2.1.1 "Eianrod" - Built: Thu Sep 11 2014 10:37:16
1138611386
*
1138711387
* By Richard Davey http://www.photonstorm.com @photonstorm
1138811388
*
@@ -11425,7 +11425,7 @@ PIXI.RenderTexture.tempMatrix = new PIXI.Matrix();
1142511425
*/
1142611426
var Phaser = Phaser || {
1142711427

11428-
VERSION: '2.1.0',
11428+
VERSION: '2.1.1',
1142911429
GAMES: [],
1143011430

1143111431
AUTO: 0,
@@ -16240,6 +16240,8 @@ Phaser.StateManager.prototype = {
1624016240

1624116241
this.setCurrentState(this._pendingState);
1624216242

16243+
this._pendingState = null;
16244+
1624316245
if (this.onPreloadCallback)
1624416246
{
1624516247
this.game.load.reset();
@@ -16261,8 +16263,6 @@ Phaser.StateManager.prototype = {
1626116263
// No init? Then there was nothing to load either
1626216264
this.loadComplete();
1626316265
}
16264-
16265-
this._pendingState = null;
1626616266
}
1626716267

1626816268
},
@@ -20772,15 +20772,20 @@ Phaser.FlexGrid.prototype = {
2077220772
* @param {array} [children] - An array of children that are used to populate the FlexLayer.
2077320773
* @return {Phaser.FlexLayer} The Layer object.
2077420774
*/
20775-
createFluidLayer: function (children) {
20775+
createFluidLayer: function (children, addToWorld) {
20776+
20777+
if (typeof addToWorld === 'undefined') { addToWorld = true; }
2077620778

2077720779
var layer = new Phaser.FlexLayer(this, this.positionFluid, this.boundsFluid, this.scaleFluid);
2077820780

20779-
this.game.world.add(layer);
20781+
if (addToWorld)
20782+
{
20783+
this.game.world.add(layer);
20784+
}
2078020785

2078120786
this.layers.push(layer);
2078220787

20783-
if (typeof children !== 'undefined')
20788+
if (typeof children !== 'undefined' && typeof children !== null)
2078420789
{
2078520790
layer.addMultiple(children);
2078620791
}
@@ -20844,15 +20849,19 @@ Phaser.FlexGrid.prototype = {
2084420849
*/
2084520850
reset: function () {
2084620851

20847-
for (var i = 0; i < this.layers.length; i++)
20852+
var i = this.layers.length;
20853+
20854+
while (i--)
2084820855
{
20849-
// Remove references to this class
20850-
this.layers[i].position = null;
20851-
this.layers[i].scale = null;
20856+
if (!this.layers[i].persist)
20857+
{
20858+
// Remove references to this class
20859+
this.layers[i].position = null;
20860+
this.layers[i].scale = null;
20861+
this.layers.slice(i, 1);
20862+
}
2085220863
}
2085320864

20854-
this.layers.length = 0;
20855-
2085620865
},
2085720866

2085820867
/**
@@ -20951,12 +20960,19 @@ Phaser.FlexLayer = function (manager, position, bounds, scale) {
2095120960
/**
2095220961
* @property {Phaser.ScaleManager} scale - A reference to the ScaleManager.
2095320962
*/
20954-
this.manager = manager;
20963+
this.manager = manager.manager;
2095520964

2095620965
/**
2095720966
* @property {Phaser.FlexGrid} grid - A reference to the FlexGrid that owns this layer.
2095820967
*/
20959-
this.grid = manager.grid;
20968+
this.grid = manager;
20969+
20970+
/**
20971+
* Should the FlexLayer remain through a State swap?
20972+
*
20973+
* @type {boolean}
20974+
*/
20975+
this.persist = false;
2096020976

2096120977
// Bound to the grid
2096220978
this.position = position;

build/custom/phaser-ninja-physics.min.js

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/custom/phaser-no-libs.js

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Phaser - http://phaser.io
99
*
10-
* v2.1.0 "Cairhien" - Built: Tue Sep 09 2014 15:35:44
10+
* v2.1.1 "Eianrod" - Built: Thu Sep 11 2014 10:37:16
1111
*
1212
* By Richard Davey http://www.photonstorm.com @photonstorm
1313
*
@@ -50,7 +50,7 @@
5050
*/
5151
var Phaser = Phaser || {
5252

53-
VERSION: '2.1.0',
53+
VERSION: '2.1.1',
5454
GAMES: [],
5555

5656
AUTO: 0,
@@ -4865,6 +4865,8 @@ Phaser.StateManager.prototype = {
48654865

48664866
this.setCurrentState(this._pendingState);
48674867

4868+
this._pendingState = null;
4869+
48684870
if (this.onPreloadCallback)
48694871
{
48704872
this.game.load.reset();
@@ -4886,8 +4888,6 @@ Phaser.StateManager.prototype = {
48864888
// No init? Then there was nothing to load either
48874889
this.loadComplete();
48884890
}
4889-
4890-
this._pendingState = null;
48914891
}
48924892

48934893
},
@@ -9397,15 +9397,20 @@ Phaser.FlexGrid.prototype = {
93979397
* @param {array} [children] - An array of children that are used to populate the FlexLayer.
93989398
* @return {Phaser.FlexLayer} The Layer object.
93999399
*/
9400-
createFluidLayer: function (children) {
9400+
createFluidLayer: function (children, addToWorld) {
9401+
9402+
if (typeof addToWorld === 'undefined') { addToWorld = true; }
94019403

94029404
var layer = new Phaser.FlexLayer(this, this.positionFluid, this.boundsFluid, this.scaleFluid);
94039405

9404-
this.game.world.add(layer);
9406+
if (addToWorld)
9407+
{
9408+
this.game.world.add(layer);
9409+
}
94059410

94069411
this.layers.push(layer);
94079412

9408-
if (typeof children !== 'undefined')
9413+
if (typeof children !== 'undefined' && typeof children !== null)
94099414
{
94109415
layer.addMultiple(children);
94119416
}
@@ -9469,15 +9474,19 @@ Phaser.FlexGrid.prototype = {
94699474
*/
94709475
reset: function () {
94719476

9472-
for (var i = 0; i < this.layers.length; i++)
9477+
var i = this.layers.length;
9478+
9479+
while (i--)
94739480
{
9474-
// Remove references to this class
9475-
this.layers[i].position = null;
9476-
this.layers[i].scale = null;
9481+
if (!this.layers[i].persist)
9482+
{
9483+
// Remove references to this class
9484+
this.layers[i].position = null;
9485+
this.layers[i].scale = null;
9486+
this.layers.slice(i, 1);
9487+
}
94779488
}
94789489

9479-
this.layers.length = 0;
9480-
94819490
},
94829491

94839492
/**
@@ -9576,12 +9585,19 @@ Phaser.FlexLayer = function (manager, position, bounds, scale) {
95769585
/**
95779586
* @property {Phaser.ScaleManager} scale - A reference to the ScaleManager.
95789587
*/
9579-
this.manager = manager;
9588+
this.manager = manager.manager;
95809589

95819590
/**
95829591
* @property {Phaser.FlexGrid} grid - A reference to the FlexGrid that owns this layer.
95839592
*/
9584-
this.grid = manager.grid;
9593+
this.grid = manager;
9594+
9595+
/**
9596+
* Should the FlexLayer remain through a State swap?
9597+
*
9598+
* @type {boolean}
9599+
*/
9600+
this.persist = false;
95859601

95869602
// Bound to the grid
95879603
this.position = position;

build/custom/phaser-no-libs.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)