Skip to content

Commit 1281bc5

Browse files
committed
Setting the scaleMode property of a Game configuration object would cause a ScaleManager TypeError in the resize method. It now stores the scale mode locally and applies it after boot (thanks @Mickawesomesque phaserjs#1534)
1 parent 3012e49 commit 1281bc5

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ Version 2.4 - "Katar" - in dev
422422
* When reusing a Tween created with an array of properties the values would get exponentially added to the TweenData internal array each time the tween was re-run (thanks @SBCGames #1747)
423423
* Reading the dimensions of a Text object would reset its resolution property (thanks @joelika #1717)
424424
* Text.addColor would incorrectly color the text stroke if set (thanks @llevkin #1893)
425+
* Setting the scaleMode property of a Game configuration object would cause a ScaleManager TypeError in the resize method. It now stores the scale mode locally and applies it after boot (thanks @Mickawesomesque #1534)
425426

426427
### Deprecated
427428

src/core/ScaleManager.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,12 @@ Phaser.ScaleManager = function (game, width, height) {
488488
*/
489489
this.onResizeContext = null;
490490

491+
/**
492+
* @property {integer} _pendingScaleMode - Used to retain the scale mode if set from config before Boot.
493+
* @private
494+
*/
495+
this._pendingScaleMode = null;
496+
491497
/**
492498
* Information saved when fullscreen mode is started.
493499
* @property {?object} _fullScreenRestore
@@ -567,6 +573,12 @@ Phaser.ScaleManager = function (game, width, height) {
567573
*/
568574
this._lastReportedGameSize = new Phaser.Rectangle();
569575

576+
/**
577+
* @property {boolean} _booted - ScaleManager booted state.
578+
* @private
579+
*/
580+
this._booted = false;
581+
570582
if (game.config)
571583
{
572584
this.parseConfig(game.config);
@@ -616,7 +628,6 @@ Phaser.ScaleManager.RESIZE = 3;
616628
*/
617629
Phaser.ScaleManager.USER_SCALE = 4;
618630

619-
620631
Phaser.ScaleManager.prototype = {
621632

622633
/**
@@ -709,6 +720,14 @@ Phaser.ScaleManager.prototype = {
709720

710721
this.grid = new Phaser.FlexGrid(this, this.width, this.height);
711722

723+
this._booted = true;
724+
725+
if (this._pendingScaleMode)
726+
{
727+
this.scaleMode = this._pendingScaleMode;
728+
this._pendingScaleMode = null;
729+
}
730+
712731
},
713732

714733
/**
@@ -722,7 +741,14 @@ Phaser.ScaleManager.prototype = {
722741

723742
if (config['scaleMode'])
724743
{
725-
this.scaleMode = config['scaleMode'];
744+
if (this._booted)
745+
{
746+
this.scaleMode = config['scaleMode'];
747+
}
748+
else
749+
{
750+
this._pendingScaleMode = config['scaleMode'];
751+
}
726752
}
727753

728754
if (config['fullScreenScaleMode'])

0 commit comments

Comments
 (0)