admin管理员组

文章数量:1431420

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.

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.

Share Improve this question edited Sep 13, 2020 at 23:54 James Skemp 8,6019 gold badges70 silver badges112 bronze badges asked Mar 9, 2020 at 18:12 Nika KurashviliNika Kurashvili 6,48410 gold badges73 silver badges152 bronze badges 2
  • How are you defining the parentDiv variable? – brae Commented Mar 10, 2020 at 15:04
  • Does this answer your question? How do I scale the scene to fullscreen? – James Skemp Commented Sep 13, 2020 at 23:54
Add a ment  | 

1 Answer 1

Reset to default 5

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.

本文标签: javascripthow to do full screen for phaser 3Stack Overflow