瀏覽代碼

日常开发

林旭祥 3 周之前
父節點
當前提交
a507fba4da
共有 2 個文件被更改,包括 13 次插入4 次删除
  1. 11 2
      src/views/game/components/basketball.vue
  2. 2 2
      src/views/game/index.vue

+ 11 - 2
src/views/game/components/basketball.vue

@@ -48,6 +48,7 @@ watch(
     if (oldData == undefined) {
       return false;
     }
+    if (gameState.state !== 'play') return;
     console.log("ppp", oldData, newData)
     if (newData == 1) {
       console.log("投篮")
@@ -849,13 +850,14 @@ const draw = () => {
         gameState.score = 0;
         gameState.time = 60;
         gameState.balls = [];
-        gameState.state = 'menu';
+        //gameState.state = 'menu';
         gameState.click = false;
         gameState.exitTimer = null;
 
         // 如果需要跳转到其他页面,可以使用路由
         // router.push('/');
-      }, 2000);
+        emit('confirmExit', { type: 1 });
+      }, 3000);
     }
 
     // 保留点击退出的功能
@@ -896,6 +898,13 @@ const initGame = async () => {
   // 开始游戏循环
   gameState.animationFrameId = requestAnimationFrame(gameLoop);
   gameState.ballY = clientObj.value.height - 90;
+  setTimeout(() => {
+    handleMouseDown();
+    setTimeout(() => {
+      handleMouseUp();
+    }, 100)
+  }, 1000)
+
 };
 
 onBeforeMount(() => {

+ 2 - 2
src/views/game/index.vue

@@ -42,11 +42,11 @@
         <!---篮球投篮-->
         <div class="columns" v-if="currentGame == 'game_basketball'">
           <div class="item left">
-            <Basketball ref="basketballLeftRef" type="left" :currentGameArea="currentGameArea[0]"
+            <Basketball ref="basketballLeftRef" type="left" @confirmExit="getExitGame" :currentGameArea="currentGameArea[0]"
               :areaStateList="areaStateList"></Basketball>
           </div>
           <div class="item right">
-            <Basketball ref="basketballRightRef" type="right" :currentGameArea="currentGameArea[1]"
+            <Basketball ref="basketballRightRef" type="right" @confirmExit="getExitGame" :currentGameArea="currentGameArea[1]"
               :areaStateList="areaStateList"></Basketball>
           </div>
         </div>