Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to do full screen for phaser 3

I am using latest phaser.

I want to know how it's possible to have full screen.

var config = {
            type: Phaser.WEBGL,
            scale: {
                mode: Phaser.Scale.Fit,
                autoCenter: Phaser.Scale.CENTER_BOTH,
                parent: parentDiv,
                width: 1920,
                height: 1080
            },

            parent: parentDiv,
        };

If i use this config and set the style (width:100%, height:100%) to the parent div, what happens is the game is still not shown on the whole screen. It's shown in the middle. Is this a correct behaviour? I want my game to have full screen for all screen sizes.

Any idea ? is this a good practice? I don't want to use custom functions for that.

like image 937
Nika Kurashvili Avatar asked Sep 14 '25 16:09

Nika Kurashvili


1 Answers

You could do:

//…
width: window.innerWidth,
height: window.innerHeight,
//…

This will set your game screen width to the entire width of the window, and the same for the height (essentially it makes your game full-screen no matter what the window dimensions are.

like image 183
Eric Avatar answered Sep 16 '25 05:09

Eric