Merge pull request #6818 from rexrainbow/bugfix-expand-scale-mode

Set gameSize equal to baseSize, for EXPAND scale mode
This commit is contained in:
Richard Davey 2024-06-06 14:35:53 +01:00 committed by GitHub
commit 228736a695
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View file

@ -1084,6 +1084,9 @@ var ScaleManager = new Class({
}
else if (this.scaleMode === CONST.SCALE_MODE.EXPAND)
{
var baseWidth = this.game.config.width;
var baseHeight = this.game.config.height;
// Resize to match parent, like RESIZE mode
// This will constrain using min/max
@ -1104,19 +1107,21 @@ var ScaleManager = new Class({
// Expand canvas size to fit game size's width or height
var scaleX = this.parentSize.width / this.gameSize.width;
var scaleX = this.parentSize.width / baseWidth;
var scaleY = this.parentSize.height / this.gameSize.height;
var scaleY = this.parentSize.height / baseHeight;
if (scaleX < scaleY)
{
this.baseSize.setSize(this.gameSize.width, this.parentSize.height / scaleX);
this.baseSize.setSize(baseWidth, this.parentSize.height / scaleX);
}
else
{
this.baseSize.setSize(this.displaySize.width / scaleY, this.gameSize.height);
this.baseSize.setSize(this.displaySize.width / scaleY, baseHeight);
}
this.gameSize.setSize(this.baseSize.width, this.baseSize.height);
styleWidth = this.baseSize.width;
styleHeight = this.baseSize.height;

View file

@ -24,6 +24,7 @@ var CONST = require('./const');
* @borrows Phaser.Scale.ScaleModes.FIT as FIT
* @borrows Phaser.Scale.ScaleModes.ENVELOP as ENVELOP
* @borrows Phaser.Scale.ScaleModes.RESIZE as RESIZE
* @borrows Phaser.Scale.ScaleModes.EXPAND as EXPAND
*
* @borrows Phaser.Scale.Zoom.NO_ZOOM as NO_ZOOM
* @borrows Phaser.Scale.Zoom.ZOOM_2X as ZOOM_2X