Ending scene in a Tween

Hi,

I’m making a credits scene for my game but i can’t manage to let my scene end when the tween is complete. I’ve been looking for an answer for an hour but didn’t find one. This is my code

        this.tweens.add({
        targets: ending,
        alpha: 1,
        duration: 5000,
        delay: 8800,
        ease: 'linear',
        yoyo: true,
        onComplete: function () {
            this.scene.stop('Credits')
            this.scene.start('Title')
        }
    }) 

Thank you in advance!

It works now! i should’ve used arrow functions like so

      this.tweens.add({
    targets: ending,
    alpha: 1,
    duration: 5000,
    delay: 8800,
    ease: 'linear',
    yoyo: true,
    onComplete: () => {
        this.scene.stop('Credits')
        this.scene.start('Title')
    }
})
1 Like