From e3d53ad6a33743a815083413242b2b72f41ef038 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Fri, 28 Feb 2014 04:15:28 +0000 Subject: [PATCH] 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) --- README.md | 2 ++ examples/wip/no-scale.js | 59 ++++++++++++++++++++++++++++++++++++++++ src/core/ScaleManager.js | 12 +++++--- 3 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 examples/wip/no-scale.js diff --git a/README.md b/README.md index b9f6195c..25f4dda5 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/examples/wip/no-scale.js b/examples/wip/no-scale.js new file mode 100644 index 00000000..037d40f3 --- /dev/null +++ b/examples/wip/no-scale.js @@ -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); + +} \ No newline at end of file diff --git a/src/core/ScaleManager.js b/src/core/ScaleManager.js index 00358ceb..4bfcc266 100644 --- a/src/core/ScaleManager.js +++ b/src/core/ScaleManager.js @@ -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(); + } } } },