How do I start the Game over scene when the ball falls into the void?
//-------------------------------- CODE --------------------------------------//
var cursors;
var player;
var score = 0;
var scoreText;
var plataforms;
class SceneB extends Phaser.Scene { constructor() { super({key: "SceneB", active: true});}
preload(){
//----------------------pleyer-------------------//
this.load.image('ball', 'assets/Ball.png');
//----------------------Background-------------------//
this.load.image('background', 'assets/img/lofi-1.jpg');
//----------------------Audio-------------------//
this.load.audio('MusicL-1','assets/audio/level-1.mp3');
//----------------------plataforms-------------------//
this.load.image('plataform','assets/plataform.png');
}
create(){
var audio = this.sound.add('MusicL-1',{loop:true}); audio.play();
//-----------------backgraund-------------//
this.add.image(400, 300, 'background').setDisplaySize(800, 600);
//-------------------- Music -------------------------------------//
var audio = this.sound.add('MusicL-1',{loop:true}); audio.play();
//-------------------- Score -------------------------------------//
scoreText=this.add.text(16, 16, 'SCORE '+ score,{ fontSize:'32px', fill:'#8357eb',fontFamily: 'verdana, arial, sans-serif'});
//-------------------- Ball phisics -------------------------------------//
player = this.physics.add.sprite(Phaser.Math.Between(0,600), 0, 'ball');
player.setDisplaySize(50,50);
player.setGravityY(14000);
player.body.setCollideWorldBounds(true);
//------------------ Create plataforms --------------//
timedEvent = this.time.addEvent({ delay: 1000, callback: createPlataforms, callbackScope: this, loop: true });
function createPlataforms(){
plataforms = this.physics.add.sprite(Phaser.Math.Between(0,800), 0, 'plataform');
plataforms.body.immovable = true;
plataforms.setDisplaySize(200, 200);
plataforms.setVelocityY(100)
plataforms.setSize(80,8);
//--------------------- coliders-------------------------//
this.physics.add.collider(player,plataforms);
plataforms.body.checkCollision.up = true;
plataforms.body.checkCollision.down = false;
plataforms.body.checkCollision.left = false;
plataforms.body.checkCollision.right = false;
this.physics.world.setBoundsCollision(true,true,true, false);
}//-------------------create controls----------//
cursors = this.input.keyboard.createCursorKeys();
LeftButton=this.add.text(16, 480, ' ◄ ',{ fontSize:'64px', fill:'#8357eb',fontFamily: 'verdana, arial, sans-serif'}).setInteractive();
RightButton=this.add.text(128, 480, ' ► ',{ fontSize:'64px', fill:'#8357eb',fontFamily: 'verdana, arial, sans-serif'}).setInteractive();
jumpButton=this.add.text(650, 480, ' ⯄ ',{ fontSize:'64px', fill:'#8357eb',fontFamily: 'verdana, arial, sans-serif'}).setInteractive();
FullScreen=this.add.text(700, 1, ' ⎚ ',{ fontSize:'64px', fill:'#8357eb',fontFamily: 'verdana, arial, sans-serif'}).setInteractive();
LeftButton.on('pointerdown', () => player.setVelocityX(-250));
RightButton.on('pointerdown', () => player.setVelocityX(250));
jumpButton.on('pointerdown', () => player.setVelocityY(-500));
FullScreen.on('pointerdown', () => this.scale.startFullscreen());
}
update(){}
}