林旭祥 3 tygodni temu
rodzic
commit
03d876a752
2 zmienionych plików z 26 dodań i 14 usunięć
  1. 4 3
      src/views/game/components/fruit.vue
  2. 22 11
      src/views/game/index.vue

+ 4 - 3
src/views/game/components/fruit.vue

@@ -1114,7 +1114,7 @@ class MainScene extends Phaser.Scene {
   getExit() {
     console.log("退出");
     // router.push({ path: '/game' });
-    emit('confirmExit', {});
+    emit('confirmExit', { type: 0 });
   }
 
   resetScene() {
@@ -1612,8 +1612,9 @@ class PlayScene extends Phaser.Scene {
         // 动画完成后再设置自动返回,确保用户有足够时间看到画面
         setTimeout(() => {
           console.log('游戏结束,返回首页');
-          this.scene.start('main');
-        }, 1000); // 延长至3秒,给用户足够时间观察
+          // this.scene.start('main');
+          emit('confirmExit', { type: 1 });
+        }, 3000);
       }
     });
 

+ 22 - 11
src/views/game/index.vue

@@ -26,42 +26,53 @@
         <div class="columns" v-if="currentGame == 'bodyposecontroller'">
           <template v-if="currentGameArea.length == 2">
             <div class="item left">
-              <HumanBody ref="humanBodyLeftRef" type="left" :currentGameArea="currentGameArea[0]" :areaStateList="areaStateList"></HumanBody>
+              <HumanBody ref="humanBodyLeftRef" type="left" :currentGameArea="currentGameArea[0]"
+                :areaStateList="areaStateList"></HumanBody>
             </div>
             <div class="item right">
-              <HumanBody ref="humanBodyRightRef" type="right" :currentGameArea="currentGameArea[1]" :areaStateList="areaStateList"></HumanBody>
+              <HumanBody ref="humanBodyRightRef" type="right" :currentGameArea="currentGameArea[1]"
+                :areaStateList="areaStateList"></HumanBody>
             </div>
           </template>
           <template v-else>
-            <HumanBody ref="humanBodyLeftRef" type="left" :currentGameArea="currentGameArea[0]" :areaStateList="areaStateList"></HumanBody>
+            <HumanBody ref="humanBodyLeftRef" type="left" :currentGameArea="currentGameArea[0]"
+              :areaStateList="areaStateList"></HumanBody>
           </template>
         </div>
         <!---篮球投篮-->
         <div class="columns" v-if="currentGame == 'game_basketball'">
           <div class="item left">
-            <Basketball ref="basketballLeftRef" type="left" :currentGameArea="currentGameArea[0]" :areaStateList="areaStateList"></Basketball>
+            <Basketball ref="basketballLeftRef" type="left" :currentGameArea="currentGameArea[0]"
+              :areaStateList="areaStateList"></Basketball>
           </div>
           <div class="item right">
-            <Basketball ref="basketballRightRef" type="right" :currentGameArea="currentGameArea[1]" :areaStateList="areaStateList"></Basketball>
+            <Basketball ref="basketballRightRef" type="right" :currentGameArea="currentGameArea[1]"
+              :areaStateList="areaStateList"></Basketball>
           </div>
         </div>
         <!---足球带球-->
         <div class="columns" v-if="currentGame == 'game_football'">
           <div class="item left">
-            <Football ref="footballLeftRef" type="left" :currentGameArea="currentGameArea[0]" :areaStateList="areaStateList"></Football>
+            <Football ref="footballLeftRef" type="left" :currentGameArea="currentGameArea[0]"
+              :areaStateList="areaStateList">
+            </Football>
           </div>
           <div class="item right">
-            <Football ref="footballRightRef" type="right" :currentGameArea="currentGameArea[1]" :areaStateList="areaStateList"></Football>
+            <Football ref="footballRightRef" type="right" :currentGameArea="currentGameArea[1]"
+              :areaStateList="areaStateList">
+            </Football>
           </div>
         </div>
         <!---切水果-->
         <div class="columns" v-if="currentGame == 'game_fruit'">
-          <Fruit ref="fruitRef" @confirmExit="getExitGame" :currentGameArea="currentGameArea[0]"  :areaStateList="areaStateList"></Fruit>
+          <Fruit ref="fruitRef" @confirmExit="getExitGame" :currentGameArea="currentGameArea[0]"
+            :areaStateList="areaStateList">
+          </Fruit>
         </div>
       </div>
     </Transition>
     <div class="close" v-if="start" @click="getExitGame"></div>
-    <ActionConfirmWindow ref="actionConfirmRef" @confirmExit="getExitGame(1)" @confirmStart="getStartGame">
+    <ActionConfirmWindow ref="actionConfirmRef" @confirmExit="getExitGame({ type: 1 })" @confirmStart="getStartGame">
     </ActionConfirmWindow>
   </div>
 </template>
@@ -238,8 +249,8 @@ const getExit = () => {
 /**
  * 退出游戏
  */
-const getExitGame = (type: any) => {
-  if (type == 1) {
+const getExitGame = (data: any) => {
+  if (data.type == 1) {
     //浮窗退出
     console.log("currentGameArea.value", currentGameArea.value)
     currentGameArea.value.forEach((item: any) => {