mirror of
https://github.com/photonstorm/phaser
synced 2024-11-15 01:17:43 +00:00
Introduced a separate stage.fullScreenScaleMode property that is used to decide scaling when fullscreen.
This commit is contained in:
parent
c5c754725a
commit
b978a2b73b
3 changed files with 46 additions and 11 deletions
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -309,6 +309,8 @@ Phaser.StageScaleMode.prototype = {
|
|||
this.event = event;
|
||||
|
||||
if (this.isFullScreen)
|
||||
{
|
||||
if (this.game.stage.fullScreenScaleMode === Phaser.StageScaleMode.EXACT_FIT)
|
||||
{
|
||||
this.game.stage.canvas.style['width'] = '100%';
|
||||
this.game.stage.canvas.style['height'] = '100%';
|
||||
|
@ -321,6 +323,13 @@ Phaser.StageScaleMode.prototype = {
|
|||
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();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
this.game.stage.canvas.style['width'] = this.game.width + 'px';
|
||||
|
@ -560,7 +569,9 @@ Phaser.StageScaleMode.prototype = {
|
|||
{
|
||||
this.setMaximum();
|
||||
}
|
||||
else if (this.game.stage.scaleMode == Phaser.StageScaleMode.EXACT_FIT)
|
||||
else if (!this.isFullScreen)
|
||||
{
|
||||
if (this.game.stage.scaleMode == Phaser.StageScaleMode.EXACT_FIT)
|
||||
{
|
||||
this.setExactFit();
|
||||
}
|
||||
|
@ -568,6 +579,18 @@ Phaser.StageScaleMode.prototype = {
|
|||
{
|
||||
this.setShowAll();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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();
|
||||
clearInterval(this._check);
|
||||
|
|
Loading…
Reference in a new issue