javascript - how to do full screen for phaser 3 - Stack Overflow

I am using latest phaser.I want to know how it's possible to have full screen.var config = {type:

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745572704a4633777.html

相关推荐

  • javascript - how to do full screen for phaser 3 - Stack Overflow

    I am using latest phaser.I want to know how it's possible to have full screen.var config = {type:

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信