From 150abc7a8ecd54bd63bbfbdd3821362469bbc138 Mon Sep 17 00:00:00 2001 From: Andres Ruiz Date: Sat, 23 Jan 2021 09:45:45 -0600 Subject: [PATCH] Render explosion on player-enemy collide Also reset the X position of the player to it's initial position --- src/scenes/PlayGame.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/scenes/PlayGame.js b/src/scenes/PlayGame.js index 994157c..4a92511 100644 --- a/src/scenes/PlayGame.js +++ b/src/scenes/PlayGame.js @@ -248,9 +248,13 @@ export class PlayGame extends Phaser.Scene { /* If the enemy spaceship and the player are the same color, then * kill the enemy and kill the player. */ if(this.isPlayerAndEnemySameColor(player.texture.key, enemy.texture.key)){ - enemy.destroy(); this.lives -= 1; this.livesText.setText("Lives: " + this.lives); + + enemy.destroy(); + this.renderExplosion({ x: enemy.x, y: enemy.y }, this.getColor(enemy.texture.key)); + this.renderExplosion({ x: player.x, y: player.y }, this.getColor(player.texture.key)); + this.player.setX(this.game.config.width / 2); } }); }