Switching scenes help?

So I’m trying to switch frome my menu scene to my game scene, but I can’t seem to figure out how. Every time I try, I get the error this.scene.start() isn’t a function/ Here’s the code.

class Scene2 extends Phaser.Scene{
    constructor(){
      super("playGame");
    }
  
    create() {
        this.cursors = this.input.keyboard.createCursorKeys()
        this.startbutton = this.add.image(250,200,"playbutton")
        this.startbutton.setOrigin(0,0)
        this.startbutton.setInteractive()
        this.startbutton.on('pointerup',function(){
          console.log("YAY")
          this.scene.start('Scene3');
        })

        this.add.text(20, 20, "Scene: 2", {font: "25px Arial", fill: "green"});

    }
}
const scene = this
this.startbutton.on('pointerup',function(){
  console.log("YAY")
  scene.scene.start('Scene3');
})

or

this.startbutton.on('pointerup', () => {
    console.log("YAY");
    this.scene.start('Scene3');
});

In the pointerup event handler, this is the game object that was clicked, unless you pass a different context as the third argument to on() or use an arrow function.

I just had to pass this as the third argument :slight_smile:

Hey I’ve got another question but it’s similar to this one. Since I’m switching to my game scene, I want a back button in the tutorial. In my third scene, I use the same code but with a back button instead of start button. Is it because that scene is already started? Nothing comes up when I press the switch button

Do you see anything? It could be underneath another scene.

Nah I don’t see anything