林旭祥 2 nedēļas atpakaļ
vecāks
revīzija
5fb50adbf1
1 mainītis faili ar 10 papildinājumiem un 8 dzēšanām
  1. 10 8
      src/views/game/components/football.vue

+ 10 - 8
src/views/game/components/football.vue

@@ -148,10 +148,10 @@ const initGame = () => {
 
   game.value.events.on('gameOver', () => {
     currentScene.value = 'gameover';
-      if (currentScene.value == 'gameover') {
-        // restartGame();
-        emit('confirmExit', { type: 2, area: props.currentGameArea });
-      }
+    if (currentScene.value == 'gameover') {
+      // restartGame();
+      emit('confirmExit', { type: 2, area: props.currentGameArea });
+    }
   });
 };
 
@@ -313,7 +313,7 @@ class GameScene extends Phaser.Scene {
 
     // 等待开始游戏信号
     this.gameActive = false;
-    
+
     startGame();
   }
 
@@ -526,9 +526,11 @@ class GameScene extends Phaser.Scene {
     }
 
     // 扣除生命值
-    player.lives--;
-    this.lives = player.lives;
-    this.livesText.setText(`生命: ${this.lives}`);
+    if (player.lives > 0) {
+      player.lives--;
+      this.lives = player.lives;
+      this.livesText.setText(`生命: ${this.lives}`);
+    }
 
     // 显示受伤效果
     player.setTexture('playerCollision');