浏览代码

日常开发

林旭祥 3 周之前
父节点
当前提交
dd6517481c
共有 2 个文件被更改,包括 41 次插入31 次删除
  1. 37 24
      src/components/ActionConfirmWindow/index.vue
  2. 4 7
      src/views/game/index.vue

+ 37 - 24
src/components/ActionConfirmWindow/index.vue

@@ -7,17 +7,7 @@
       :leave-active-class="proxy?.animate.rankingWindow.leave">
       :leave-active-class="proxy?.animate.rankingWindow.leave">
       <div class="confirmDiaBg" v-if="actionState">
       <div class="confirmDiaBg" v-if="actionState">
         <div class="confirmDiaWindow">
         <div class="confirmDiaWindow">
-          <div class="prompt"><i></i> <template v-if="currentGame == 'game_fruit'">
-              举手开始游戏
-            </template>
-            <template v-if="currentGame == 'game_basketball'">
-              请做投篮动作开始游戏
-            </template>
-            <template v-if="currentGame == 'game_football'">
-              请踢腿开始游戏
-            </template>
-          </div>
-
+          <div class="prompt"><i></i> {{ actionText }}</div>
           <div class="confirmDiaWindow-con">
           <div class="confirmDiaWindow-con">
             <div class="picBox">
             <div class="picBox">
               <div class="pic">
               <div class="pic">
@@ -35,6 +25,12 @@
                 <div class="gamePlayer">
                 <div class="gamePlayer">
                   <div class="item" v-for="item in areaStateList" :key="item.area">
                   <div class="item" v-for="item in areaStateList" :key="item.area">
                     <div class="player">
                     <div class="player">
+                      <template v-if="currentGame == 'bodyposecontroller'">
+                        <div><img src="@/assets/images/game/fruit1.png" class="fade-image"
+                            :class="{ 'fade-image1': !item.state }"></img></div>
+                        <div><img v-if="!item.state" src="@/assets/images/game/fruit2.png" class="fade-image"
+                            :class="{ 'fade-image2': !item.state }"></img></div>
+                      </template>
                       <template v-if="currentGame == 'game_fruit'">
                       <template v-if="currentGame == 'game_fruit'">
                         <div><img src="@/assets/images/game/fruit1.png" class="fade-image"
                         <div><img src="@/assets/images/game/fruit1.png" class="fade-image"
                             :class="{ 'fade-image1': !item.state }"></img></div>
                             :class="{ 'fade-image1': !item.state }"></img></div>
@@ -83,9 +79,11 @@ const data = reactive<any>({
   actionState: false,//窗口状态
   actionState: false,//窗口状态
   areaStateList: [],
   areaStateList: [],
   lock: false,
   lock: false,
+  actionText: "",
+  timer: null,
 });
 });
 
 
-const { currentGame, currentGameArea, actionState, areaStateList, lock } = toRefs(data);
+const { currentGame, currentGameArea, actionState, areaStateList, lock, actionText, timer } = toRefs(data);
 
 
 
 
 
 
@@ -110,12 +108,19 @@ const getInit = (e: any) => {
   }
   }
   //console.log("result", result)
   //console.log("result", result)
   if (currentGame.value == 'bodyposecontroller') {
   if (currentGame.value == 'bodyposecontroller') {
-    let myIndex = areaStateList.value.findIndex((item: any) => {
-      return item.area == area;
-    })
-    let boxes = [{ x: arr[0], y: arr[3] }, { x: arr[0], y: arr[1] }, { x: arr[2], y: arr[1] }, { x: arr[2], y: arr[3] }];
-    areaStateList.value[myIndex].state = true;
-    areaStateList.value[myIndex].boxes = boxes;
+    let leftA = result[6][1];//右肩Y
+    let rightA = result[5][1];//左肩Y
+    let leftB = result[10][1];//右手Y
+    let rightB = result[9][1];//左手Y
+    let bizi = result[0][1];//鼻子Y
+    if (leftB < leftA || rightB < rightA || leftB < bizi || rightB < bizi) {
+      let myIndex = areaStateList.value.findIndex((item: any) => {
+        return item.area == area;
+      })
+      let boxes = [{ x: arr[0], y: arr[3] }, { x: arr[0], y: arr[1] }, { x: arr[2], y: arr[1] }, { x: arr[2], y: arr[3] }];
+      areaStateList.value[myIndex].state = true;
+      areaStateList.value[myIndex].boxes = boxes;
+    }
   }
   }
   if (currentGame.value == 'game_basketball') {
   if (currentGame.value == 'game_basketball') {
     let leftA = result[6][1];//右肩Y
     let leftA = result[6][1];//右肩Y
@@ -247,21 +252,29 @@ const getOpen = async (game: any, area: any) => {
   }) || [];
   }) || [];
   areaStateList.value = list;
   areaStateList.value = list;
   actionState.value = true;
   actionState.value = true;
+  let txt = ""
+  if (currentGame.value == 'bodyposecontroller') {
+    txt = "举手开始游戏";
+  }
   if (currentGame.value == 'game_fruit') {
   if (currentGame.value == 'game_fruit') {
-    speckText("举手开始游戏");
+    txt = "举手开始游戏";
   }
   }
   if (currentGame.value == 'game_basketball') {
   if (currentGame.value == 'game_basketball') {
-    speckText("请做投篮动作开始游戏");
+    txt = "请做投篮动作开始游戏";
   }
   }
   if (currentGame.value == 'game_football') {
   if (currentGame.value == 'game_football') {
-    speckText("请踢腿开始游戏");
+    txt = "请踢腿开始游戏";
   }
   }
+  actionText.value = txt;
+  speckText(actionText.value);
 };
 };
 
 
 /**
 /**
  * 关闭
  * 关闭
 */
 */
 const getExit = () => {
 const getExit = () => {
+  clearInterval(timer.value);
+  timer.value = null;
   speckCancel(); //停止播报
   speckCancel(); //停止播报
   actionState.value = false;
   actionState.value = false;
   emit('confirmExit', {});
   emit('confirmExit', {});
@@ -283,11 +296,11 @@ watch(
     if (state) {
     if (state) {
       lock.value = true;
       lock.value = true;
       let num = 3;
       let num = 3;
-      let timer: any = setInterval(() => {
+      timer.value = setInterval(() => {
         if (num == 1) {
         if (num == 1) {
           actionState.value = false;
           actionState.value = false;
-          clearInterval(timer);
-          timer = null;
+          clearInterval(timer.value);
+          timer.value = null;
           emit('confirmStart', areaStateList.value);
           emit('confirmStart', areaStateList.value);
         }
         }
         speckText(num);
         speckText(num);

+ 4 - 7
src/views/game/index.vue

@@ -148,19 +148,13 @@ const getInit = async () => {
       let area = e.ctrl_name.replace('bodyposecontroller_', '');
       let area = e.ctrl_name.replace('bodyposecontroller_', '');
       if (e?.code == 0) {
       if (e?.code == 0) {
         getBodyposeState(area);
         getBodyposeState(area);
-      } else {
-        setTimeout(() => {
-          checkBodypose(area);
-        }, 500)
       }
       }
     }
     }
     if (e?.cmd == 'get_bodyposecontroller_state') {
     if (e?.cmd == 'get_bodyposecontroller_state') {
       let area = e.ctrl_name.replace('bodyposecontroller_', '');
       let area = e.ctrl_name.replace('bodyposecontroller_', '');
       //state说明: 0:关闭,3:空闲,36:工作中
       //state说明: 0:关闭,3:空闲,36:工作中
       if ([3, 36].includes(e.state)) {
       if ([3, 36].includes(e.state)) {
-        setTimeout(() => {
-          terminateBodypose(area);
-        }, 500)
+        terminateBodypose(area);
       } else {
       } else {
         openBodypose(area);
         openBodypose(area);
       }
       }
@@ -246,12 +240,15 @@ const getExit = () => {
  */
  */
 const getExitGame = (type: any) => {
 const getExitGame = (type: any) => {
   if (type == 1) {
   if (type == 1) {
+    //浮窗退出
+    console.log("currentGameArea.value", currentGameArea.value)
     currentGameArea.value.forEach((item: any) => {
     currentGameArea.value.forEach((item: any) => {
       terminateBodypose(item);
       terminateBodypose(item);
     })
     })
     currentGame.value = "";
     currentGame.value = "";
     start.value = false;
     start.value = false;
   } else {
   } else {
+    //游戏中退出
     proxy?.$modal.confirm("确定退出吗?").then(() => {
     proxy?.$modal.confirm("确定退出吗?").then(() => {
       currentGameArea.value.forEach((item: any) => {
       currentGameArea.value.forEach((item: any) => {
         terminateBodypose(item);
         terminateBodypose(item);