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 #258)
This commit is contained in:
photonstorm 2014-02-28 04:15:28 +00:00
parent 09d4a35b7f
commit e3d53ad6a3
3 changed files with 69 additions and 4 deletions

View file

@ -82,6 +82,7 @@ Significant API changes:
* 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.
* Time.physicsElapsed is no longer bound or clamped, be wary of this if you use the value anywhere in your code.
* 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.
* Game no longer pauses if you've forced orientation and change it, also doesn't resize a NO_SCALE game.
New features:
@ -185,6 +186,7 @@ Bug Fixes:
* Calling destroy on an already destroyed object would throw a run-time error. Now checked for and aborted.
* Calling destroy while in an Input Event callback now works for either the parent Group or the calling object itself.
* Loader.replaceInFileList wouldn't over-write the previous entry correctly, which caused the Loader.image overwrite parameter to fail (thanks basoko, fixes #493)
* 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)
TO DO:

59
examples/wip/no-scale.js Normal file
View file

@ -0,0 +1,59 @@
var game = new Phaser.Game(1024, 672, Phaser.CANVAS, 'phaser-example', { init: init, preload: preload, create: create, update: update, render: render });
function init() {
game.scale.scaleMode = Phaser.ScaleManager.NO_SCALE;
// game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
game.scale.forceOrientation(true, false);
game.scale.enterIncorrectOrientation.add(enterIncorrectOrientation, game);
game.scale.leaveIncorrectOrientation.add(leaveIncorrectOrientation, game);
game.scale.setScreenSize(true);
game.stage.backgroundColor = 0x004400;
}
function preload() {
game.load.image('pic', 'assets/pics/remember-me.jpg');
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
}
var mummy;
var anim;
function create() {
game.add.image(0, 0, 'pic');
mummy = game.add.sprite(300, 200, 'mummy', 5);
anim = mummy.animations.add('walk');
anim.play(20, true);
}
function enterIncorrectOrientation () {
// game.stage.backgroundColor = 0xff0000;
}
function leaveIncorrectOrientation () {
// game.stage.backgroundColor = 0x000033;
}
function update() {
}
function render() {
// game.debug.renderPointer(game.input.activePointer);
}

View file

@ -409,7 +409,6 @@ Phaser.ScaleManager.prototype = {
if ((this.forceLandscape && window.innerWidth > window.innerHeight) || (this.forcePortrait && window.innerHeight > window.innerWidth))
{
// Back to normal
this.game.paused = false;
this.incorrectOrientation = false;
this.leaveIncorrectOrientation.dispatch();
@ -419,7 +418,10 @@ Phaser.ScaleManager.prototype = {
this.game.world.visible = true;
}
this.refresh();
if (this.scaleMode !== Phaser.ScaleManager.NO_SCALE)
{
this.refresh();
}
}
}
else
@ -427,7 +429,6 @@ Phaser.ScaleManager.prototype = {
if ((this.forceLandscape && window.innerWidth < window.innerHeight) || (this.forcePortrait && window.innerHeight < window.innerWidth))
{
// Show orientation screen
this.game.paused = true;
this.incorrectOrientation = true;
this.enterIncorrectOrientation.dispatch();
@ -437,7 +438,10 @@ Phaser.ScaleManager.prototype = {
this.game.world.visible = false;
}
this.refresh();
if (this.scaleMode !== Phaser.ScaleManager.NO_SCALE)
{
this.refresh();
}
}
}
},