Camera follow breaks after browser resize


#1

I have a camera that follows the player using cameras.main.startFollow(this.leviathan);

I’ve set mode: Phaser.Scale.RESIZE

The game appears to scale correctly when I resize the browser window, but the behavior of the camera follow breaks.

Something else worth noting is that if I kill the app, resize the browser, and reload it, then everything works just fine. It’s like I need to do whatever is happening under the hood of Phaser.Scale.RESIZE every time the browser changes size.

Any tips here? Haven’t had any success searching this forum or in the API docs. Thanks very much!


#3

For posterity: turns out that while setting Phaser.Scale.RESIZE doesn’t auto-resize the main camera. so in create(), I had to do:

this.scale.on('resize', () => {
      this.cameras.main.setSize(window.innerWidth, window.innerHeight);
    });