I am using Phaser version 3.55.2, what is wrong here? Does Phaser not allow to pass scene as parameter and restart on that? I am new to Phaser. plz help me to figure out what is going on here. Thank you.
var config = {
type: Phaser.AUTO,
parent: 'phaser-example',
width: innerWidth * 0.9,
height: innerHeight * 0.9,
scene: [Level],
backgroundColor: 0xE4004D
}
const game = new Phaser.Game(config);
class Level extends Phaser.Scene {
constructor() {
super("bubbleSort")
}
create(){
.......
this.event=new UserEventHandler({ctx:this})
this.event.createRestartBtn(0,0);
}
}
class UserEventHandler {
constructor(con) {
this.ctx = con.ctx;
}
createRestartBtn(x, y) {
this.rst = this.ctx.add.text(x, y, 'Restart', {
font: '30px CustomFont',
fill: '#f1c27d',
align: 'center'
});
this.rst.setOrigin(0.5, 0.5);
this.rst.setInteractive({ useHandCursor: true });
this.rst.on('pointerover', () => {
this.rst.setFill('#ffffff')
this.rst.setFontSize(35)
});
this.rst.on('pointerout', () => {
this.rst.setFill('#f1c27d')
this.rst.setFontSize(30)
});
this.rst.on('pointerdown',()=>{
this.ctx.scene.restart();
});
}
}