Responsive game size in mobile browser

I am glad that my decision helped you.
You can play around with this.

        let bg = this.add.image(window.innerWidth / 2, window.innerHeight / 2, 'bg')
        bg.orgWidth = bg.displayWidth
        bg.orgHeight = bg.displayHeight
        bg.update = function () {
            if (app.width * this.orgHeight/this.orgWidth < app.height){
                this.displayWidth = app.height * this.orgWidth/this.orgHeight
                this.displayHeight = app.height
            }else{
                this.displayWidth = app.width
                this.displayHeight = app.width * this.orgHeight/this.orgWidth
            }
        }

GIF 14.08.2022 7-06-29

In the horizontal view, it will always adjust proportionally in width, if the portrait view is proportional in height.

1 Like