Browse Source

日常开发

林旭祥 17 hours ago
parent
commit
5729ac8e3c
1 changed files with 14 additions and 8 deletions
  1. 14 8
      src/views/game/fruit.vue

+ 14 - 8
src/views/game/fruit.vue

@@ -1198,25 +1198,31 @@ class PlayScene extends Phaser.Scene {
 
   gameOver() {
     this.playing = false;
-
+    // 显示游戏结束图片
     const gameOverSprite = this.add.sprite(width / 2, height / 2, 'game-over');
     gameOverSprite.setOrigin(0.5, 0.5);
     gameOverSprite.setScale(0);
 
+    // 添加入场动画
     this.tweens.add({
       targets: gameOverSprite,
       scale: 1,
-      duration: 300,
+      duration: 400,
       ease: 'Sine.InOut'
     });
+
+    // 确保2秒后自动返回首页,增加日志确认执行
+    console.log('游戏结束,准备返回首页...');
     setTimeout(() => {
-      this.scene.start('main');
-    }, 2000)
+      console.log('执行返回首页操作');
+      this.scene.start('main'); // 切换到主场景(首页)
+    }, 2000);
 
-    // 点击重新开始
-    // this.input.once('pointerup', () => {
-    //   this.scene.start('main');
-    // });
+    // 保留点击立即返回的逻辑(可选)
+    this.input.once('pointerup', () => {
+      console.log('点击立即返回首页');
+      this.scene.start('main');
+    });
   }
 }