Ver código fonte

日常开发

林旭祥 2 semanas atrás
pai
commit
2674f3d1f8
1 arquivos alterados com 15 adições e 1 exclusões
  1. 15 1
      src/views/game/components/fruit.vue

+ 15 - 1
src/views/game/components/fruit.vue

@@ -1128,6 +1128,11 @@ class MainScene extends Phaser.Scene {
       this.sandiaGroup = null; // 置空引用
     }
   }
+
+restartGame() {
+  this.resetScene();
+  this.scene.start("play");
+}
 }
 
 // 游戏场景
@@ -1698,7 +1703,16 @@ const getActiveScene = () => {
 
 // 再次游戏
 const getResumeGame = async () => {
-
+    const game = gameRef.value;
+    if (game) {
+      const mainScene = game.scene.getScene('main');
+      if (mainScene) {
+        mainScene.restartGame();
+      } else {
+        // 如果主场景未激活,直接启动游戏场景
+        game.scene.start('play');
+      }
+    }
 };
 
 onBeforeMount(() => {