diff --git a/examples/display/fullscreen.js b/examples/display/fullscreen.js index 5f38a7fa3..5c5932f8d 100644 --- a/examples/display/fullscreen.js +++ b/examples/display/fullscreen.js @@ -13,6 +13,13 @@ function create() { game.stage.backgroundColor = '#e3ed49'; + // Stretch to fill +// game.stage.fullScreenScaleMode = Phaser.StageScaleMode.EXACT_FIT; + // Keep original size +// game.stage.fullScreenScaleMode = Phaser.StageScaleMode.NO_SCALE; + // Maintain aspect ratio + game.stage.fullScreenScaleMode = Phaser.StageScaleMode.NO_SCALE; + game.input.onDown.add(gofull, this); } diff --git a/src/core/Stage.js b/src/core/Stage.js index 12b053a21..44d0a0fd3 100644 --- a/src/core/Stage.js +++ b/src/core/Stage.js @@ -52,6 +52,11 @@ Phaser.Stage = function (game, width, height) { */ this.scaleMode = Phaser.StageScaleMode.NO_SCALE; + /* + * @property {number} fullScreenScaleMode - Scale mode to be used in fullScreen + */ + this.fullScreenScaleMode = Phaser.StageScaleMode.NO_SCALE; + /** * @property {Phaser.StageScaleMode} scale - The scale of the current running game. */ diff --git a/src/system/StageScaleMode.js b/src/system/StageScaleMode.js index f3abb0098..70079717b 100644 --- a/src/system/StageScaleMode.js +++ b/src/system/StageScaleMode.js @@ -310,16 +310,25 @@ Phaser.StageScaleMode.prototype = { if (this.isFullScreen) { - this.game.stage.canvas.style['width'] = '100%'; - this.game.stage.canvas.style['height'] = '100%'; + if (this.game.stage.fullScreenScaleMode === Phaser.StageScaleMode.EXACT_FIT) + { + this.game.stage.canvas.style['width'] = '100%'; + this.game.stage.canvas.style['height'] = '100%'; - this.setMaximum(); + this.setMaximum(); - this.game.input.scale.setTo(this.game.width / this.width, this.game.height / this.height); + this.game.input.scale.setTo(this.game.width / this.width, this.game.height / this.height); + + this.aspectRatio = this.width / this.height; + this.scaleFactor.x = this.game.width / this.width; + this.scaleFactor.y = this.game.height / this.height; + } + else if (this.game.stage.fullScreenScaleMode === Phaser.StageScaleMode.SHOW_ALL) + { + this.game.stage.scale.setShowAll(); + this.game.stage.scale.refresh(); + } - this.aspectRatio = this.width / this.height; - this.scaleFactor.x = this.game.width / this.width; - this.scaleFactor.y = this.game.height / this.height; } else { @@ -560,13 +569,27 @@ Phaser.StageScaleMode.prototype = { { this.setMaximum(); } - else if (this.game.stage.scaleMode == Phaser.StageScaleMode.EXACT_FIT) + else if (!this.isFullScreen) { - this.setExactFit(); + if (this.game.stage.scaleMode == Phaser.StageScaleMode.EXACT_FIT) + { + this.setExactFit(); + } + else if (this.game.stage.scaleMode == Phaser.StageScaleMode.SHOW_ALL) + { + this.setShowAll(); + } } - else if (this.game.stage.scaleMode == Phaser.StageScaleMode.SHOW_ALL) + else { - this.setShowAll(); + if (this.game.stage.fullScreenScaleMode == Phaser.StageScaleMode.EXACT_FIT) + { + this.setExactFit(); + } + else if (this.game.stage.fullScreenScaleMode == Phaser.StageScaleMode.SHOW_ALL) + { + this.setShowAll(); + } } this.setSize();