GameObjects stop responding to input events after game recreated with scale.mode

Issue on Phaser3 github #4862

Version

  • Phaser Version: v3.20.1
  • Operating system: Linux (the issue should not be platform-related)
  • Browser: Version 78.0.3904.87 (Official Build) (64-bit)

Description

GameObjects stop responding to input events after game recreated with scale.mode

Example Test Code

try inserting this code in any Phaser3 Labs example:

const config = {
    type: Phaser.AUTO,
    parent: 'phaser-example',
    scale: {
        mode: Phaser.Scale.RESIZE,
        width: 800, 
        height: 600
    },
    scene: {
        create: create
    }
};

let game = new Phaser.Game(config);

function create ()
{
    this.add.text(10, 10, 'text text text', { font: '16px Courier', fill: '#00ff00' }).setInteractive().on('pointerdown', function () {
        console.log('this.style.color '+this.style.color)
        this.style.color == '#ff0000' ? this.setColor('#00ff00') : this.setColor('#ff0000')
    })

    this.add.text(10, 400, 'destroy game', { font: '16px Courier', fill: '#00ffff' }).setInteractive().on('pointerdown', function () {

        this.sys.game.destroy(true);
        game = new Phaser.Game(config);

    }, this);
}

Steps to reproduce:

  1. click the ‘text text text’ - it will change color (respond to click events)
  2. click ‘destroy game’
  3. click the ‘text text text’ - it will not change color (not respond to click events)
  4. then change mode: Phaser.Scale.RESIZE to mode: Phaser.Scale.FIT on line 5 or any other (except NONE) - text input will still not work after game destroy
  5. then change mode: Phaser.Scale.RESIZE to mode: Phaser.Scale.NONE on line 5 - text input will work