How can i make a game over when the player touch 'lava'?

I mean… when the player touch other platform, called ‘lava’, there’s a game over.

I used the same physics of the bombs but with lava:

´function hitlava (player, lava)

    {

        this.physics.pause();

        player.setTint(0xff0000);

        player.anims.play('turn');

        gameOver = true;

    }

But it does not work, the player is able to stay in the red platform.

I also created the ‘lava’ like a normal platform:

lava = this.physics.add.staticGroup();
lava.create(500,900, 'lava').setScale(5).refreshBody();

I need some help, can you please help me? i will be thankful ^^

regards!

I dont know the way you register the colliders between.
In Arcade Physics, it must be:
this.physics.add.collider(gameObject, lava, hitlava);
and inside hitlava, thats the tricky. Try this, if there is a console printed, then you modify it:

function hitlava (player, lava) {
  gameOver= true;
  player.body.enableBody(false);
  console.log("Call gameOver Scene here! Don't pause the physics");
}

some of example: http://labs.phaser.io/edit.html?src=src\physics\arcade\collision%20direction.js

1 Like

well, i’ll try, but i don’t know how to made a scene, since when i try to make another scene, i just get a black screen… however, thanks!

EDTI: I DID IT!!! THANKS YOU BRO.

Now i just need to make a scense and call it for the game over… however, as i said above, i can’t because i just get a black screen…

3 Likes