Full screen, scaling and resizing question

in this prototype I’m currently configuring the game as follows:

export default new Phaser.Game({
  type: Phaser.AUTO,
  scale: {
    parent: 'mygame',
    mode: Phaser.Scale.FIT,
    autoCenter: Phaser.Scale.CENTER_BOTH,
    width: SCREEN_WIDTH,
    height: SCREEN_HEIGHT
  },
  scene: [Intro, Credits, Game]
})

where SCREEN_WIDTH and SCREEN_HEIGHT are constants giving a portrait aspect. In the Intro scene, I have a button to go full screen. The Game scene hosts a maze which I create dynamically.
My intent is to have a viewport as large as the full screen when in the Game scene, so I can layout my maze accordingly, however my attempts have failed. I tried this.scale.setGameSize(window.width, window.height) or this.scale.resize(window.width, window.height) from the scene create method, but in both cases an error Error: Framebuffer status: Incomplete Attachment is thrown (with or without entering full screen).

What is the correct way to adapt the game size to the window size, both in full screen mode and regular mode?

Seems like setGameSize(…) should work but you probably have to wait until fullscreen starts to get the new window dimensions.

The Incomplete Attachment error sounds like a bug.

I am setting the fullscreen in a Intro scene, and after the user clicks a button to starts the game calling setGameSize() in create() on the Game scene, so it is after…however I get that error (in fact, I get it even without setting full screen).

I filed this.scale.setGameSize(window.width, window.height) throwing error · Issue #5525 · photonstorm/phaser · GitHub, as I can reproduce the error in a trivial example.

Anybody here got scale.setGameSize(window.width, window.height) to work?

You need to use window.innerWidth, window.innerHeight, and the ENTER_FULLSCREEN event.

I think the error I’m observing is independent on whether I entered full screen or not. Or are you implying that I can call scale.setGameSize() only as a reaction to entering full screen? see my example in Issue #5525

I think you’re getting the error because window.width and window.height are undefined. You need to use window.innerWidth and window.innerHeight instead.

If you want to use the new window dimensions once entering fullscreen, you need to use the ENTER_FULLSCREEN event; before that event the dimensions haven’t changed yet.

Ah, gotcha. You’re correct, that fixed it. . I guess I still am not used to Javascript enough to think about it being perfectly happy with undefined variables being passed to a function.