Skip to content

Commit e3d53ad

Browse files
committed
Game no longer pauses if you've forced orientation and change it, also doesn't resize a NO_SCALE game.
If the game was set to NO_SCALE and you swapped orientation, it would pause and resize, then fail to resize when you swapped back (thanks starnut, fixes phaserjs#258)
1 parent 09d4a35 commit e3d53ad

3 files changed

Lines changed: 69 additions & 4 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Significant API changes:
8282
* If your game references the old Phaser.StageScaleMode consts like SHOW_ALL you need to update them to Phaser.ScaleManager, i.e. Phaser.ScaleManager.SHOW_ALL.
8383
* Time.physicsElapsed is no longer bound or clamped, be wary of this if you use the value anywhere in your code.
8484
* In Group.destroy the default for 'destroyChildren' was false. It's now `true` as this is a far more likely requirement when destroying a Group.
85+
* Game no longer pauses if you've forced orientation and change it, also doesn't resize a NO_SCALE game.
8586

8687

8788
New features:
@@ -185,6 +186,7 @@ Bug Fixes:
185186
* Calling destroy on an already destroyed object would throw a run-time error. Now checked for and aborted.
186187
* Calling destroy while in an Input Event callback now works for either the parent Group or the calling object itself.
187188
* Loader.replaceInFileList wouldn't over-write the previous entry correctly, which caused the Loader.image overwrite parameter to fail (thanks basoko, fixes #493)
189+
* If the game was set to NO_SCALE and you swapped orientation, it would pause and resize, then fail to resize when you swapped back (thanks starnut, fixes #258)
188190

189191

190192
TO DO:

examples/wip/no-scale.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
var game = new Phaser.Game(1024, 672, Phaser.CANVAS, 'phaser-example', { init: init, preload: preload, create: create, update: update, render: render });
3+
4+
function init() {
5+
6+
game.scale.scaleMode = Phaser.ScaleManager.NO_SCALE;
7+
// game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
8+
game.scale.forceOrientation(true, false);
9+
game.scale.enterIncorrectOrientation.add(enterIncorrectOrientation, game);
10+
game.scale.leaveIncorrectOrientation.add(leaveIncorrectOrientation, game);
11+
game.scale.setScreenSize(true);
12+
13+
game.stage.backgroundColor = 0x004400;
14+
15+
}
16+
17+
function preload() {
18+
19+
game.load.image('pic', 'assets/pics/remember-me.jpg');
20+
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
21+
22+
}
23+
24+
var mummy;
25+
var anim;
26+
27+
function create() {
28+
29+
game.add.image(0, 0, 'pic');
30+
31+
mummy = game.add.sprite(300, 200, 'mummy', 5);
32+
33+
anim = mummy.animations.add('walk');
34+
35+
anim.play(20, true);
36+
37+
}
38+
39+
function enterIncorrectOrientation () {
40+
41+
// game.stage.backgroundColor = 0xff0000;
42+
43+
}
44+
45+
function leaveIncorrectOrientation () {
46+
47+
// game.stage.backgroundColor = 0x000033;
48+
49+
}
50+
51+
function update() {
52+
53+
}
54+
55+
function render() {
56+
57+
// game.debug.renderPointer(game.input.activePointer);
58+
59+
}

src/core/ScaleManager.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,6 @@ Phaser.ScaleManager.prototype = {
409409
if ((this.forceLandscape && window.innerWidth > window.innerHeight) || (this.forcePortrait && window.innerHeight > window.innerWidth))
410410
{
411411
// Back to normal
412-
this.game.paused = false;
413412
this.incorrectOrientation = false;
414413
this.leaveIncorrectOrientation.dispatch();
415414

@@ -419,15 +418,17 @@ Phaser.ScaleManager.prototype = {
419418
this.game.world.visible = true;
420419
}
421420

422-
this.refresh();
421+
if (this.scaleMode !== Phaser.ScaleManager.NO_SCALE)
422+
{
423+
this.refresh();
424+
}
423425
}
424426
}
425427
else
426428
{
427429
if ((this.forceLandscape && window.innerWidth < window.innerHeight) || (this.forcePortrait && window.innerHeight < window.innerWidth))
428430
{
429431
// Show orientation screen
430-
this.game.paused = true;
431432
this.incorrectOrientation = true;
432433
this.enterIncorrectOrientation.dispatch();
433434

@@ -437,7 +438,10 @@ Phaser.ScaleManager.prototype = {
437438
this.game.world.visible = false;
438439
}
439440

440-
this.refresh();
441+
if (this.scaleMode !== Phaser.ScaleManager.NO_SCALE)
442+
{
443+
this.refresh();
444+
}
441445
}
442446
}
443447
},

0 commit comments

Comments
 (0)