I have a game that automatically plays in full screen with
this.scale.startFullscreen();
and i want to give a user an option to quit full screen by pressing 'x' in top right corner. So i wrote:
this.add.text(750, 20, 'X', { fontSize: '20px'});
this.exitFullScreen = this.add.rectangle(770, 30, 60, 60, 0xfff);
this.exitFullScreen.setInteractive();
this.exitFullScreen.on('pointerup', this.scale.stopfullScreen);
but that doesn't work, i also tried putting this.scale.stopfullScreen inside a callback function and i also added conditional if (isFullscreen()), but that didn't work either. Is there any way i can give user an option to quit full screen, ideally without removing this.scale.startFullscreen(); at the beginning of create()?