Problems with collisions

I want when the ball collides with the platform to start the gameOver scene. try with:

this.gameOverBar = 
this.physics.add.sprite(400, 600, 'plataform')
.setSize(190,8)
.setDisplaySize(1100,400);

this.physics.add.collider(this.gameOverBar, player, GameOver);
function GameOver(){this.scene.add("SceneC", new SceneC)}

but when the ball collides the screen freezes

¿How do I call the gameOver function when the Ball
collide with bar?

this.physics.add.collider(this.gameOverBar, player, GameOver);

Open the dev console in the browser and look for errors.

But I would guess you need to pass callbackContext:

this.physics.add.collider(this.gameOverBar, player, GameOver, null, this);
1 Like