Hello, here is what I have in my object (Something.js) code:
class Something extends Phaser.GameObjects.Image {
constructor(scene, x, y, toScene){
super(scene, x, y, "button");
scene.add.existing(this);
this.scene = scene;
this.setInteractive({useHandCursor: true});
this.on("pointerdown", this.changeScene, this);
this.toScene = toScene;
}
changeScene(pointer){
this.scene.switch(this.toScene);
}
}
I create my object in one of my scenes create() like that:
this.button1 = new Something(this, 100, 200, "anotherScene");
When I click in the button, I get the error “this.scene.switch is not a function”.
How do I do to switch the scene that the object belongs to? (It needs to be the scene where the object is, since I have two scenes running together and I don’t want to stop the other)