Search the Community
Showing results for tags 'StageScaleMode'.
-
Hi everyone, I really want to use whole browser window but keep my game correctly scaled. Is there any easy way how to make game height variable with fixed width using current scale modes? I've tried several approaches without any luck. Same resize method but horizontal (which doesn't really matter) can be seen for example on http://www.goodboydigital.com/runpixierun/ Thanks a lot!
-
When game goes fullscren it alwas stretch the game to width: 100% and height 100% and I don't think that this always sutes the needs: So I tried some changes to: fullScreenChange /** * Called automatically when the browser enters of leaves full screen mode. * @method Phaser.StageScaleMode#fullScreenChange * @param {Event} event - The fullscreenchange event * @protected */ fullScreenChange: function (event) { if (this.isFullScreen) { //this.game.stage.canvas.style['width'] = '100%'; //this.game.stage.canvas.style['height'] = '100%'; //this.game.stage.canvas.style['width'] = screen.width + 'px'; //this.game.stage.canvas.style['height'] = screen.height + 'px'; if(this.game.stage.scaleMode == Phaser.StageScaleMode.EXACT_FIT) { //what was default till now this.game.stage.canvas.style['width'] = '100%'; this.game.stage.canvas.style['height'] = '100%'; this.setMaximum(); 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.scaleMode == Phaser.StageScaleMode.NO_SCALE) { //no scale black strips around the display //if the screen size is bigger than the game size //do nothing } else if (this.game.stage.scaleMode == Phaser.StageScaleMode.SHOW_ALL) { //preserve aspect ratio, horizontal black lines or vertical black lines this.game.stage.scale.setShowAll(); this.game.stage.scale.refresh(); } } else { this.game.stage.canvas.style['width'] = this.game.width + 'px'; this.game.stage.canvas.style['height'] = this.game.height + 'px'; this.width = this._width; this.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; } }With this code there are checks and when you go fullscreen you can still preserve you game aspect ratio: for example a 800 x 600 game and maximize visible area. Also you can choose NO_SCALE and if the game size is lower than the screen resolution for example 400 x 600 game on almost any display will be centered in the full screen. So what is your vision about how the full screen should work... and is there other way of going full screen a preserving aspect ratio ?
- 1 reply
-
- fullScreenChange
- StageScaleMode
-
(and 1 more)
Tagged with: