林旭祥 il y a 3 semaines
Parent
commit
38eb130282

+ 1 - 1
src/views/game/components/basketball.vue

@@ -857,7 +857,7 @@ const draw = () => {
         // 如果需要跳转到其他页面,可以使用路由
         // router.push('/');
         emit('confirmExit', { type: 2, area: props.currentGameArea });
-      }, 5000);
+      }, 500);
     }
 
     // 保留点击退出的功能

+ 38 - 29
src/views/game/components/football.vue

@@ -40,11 +40,11 @@
     </div>
 
     <!-- 倒计时 -->
-    <div v-if="currentScene === 'countdown'" class="daoju">
+    <!-- <div v-if="currentScene === 'countdown'" class="daoju">
       <div class="daojishibox">
         <div class="daojishinum">{{ countdownNum }}</div>
       </div>
-    </div>
+    </div> -->
 
     <!-- 游戏结束 -->
     <div v-if="currentScene === 'gameover'" class="gameend">
@@ -95,7 +95,7 @@ const { clientObj, boxes, proportion, myThrow, myTimer, direction } = toRefs(dat
 // 游戏状态管理
 const currentScene = ref('start');
 const showRules = ref(false);
-const countdownNum = ref(3);
+// const countdownNum = ref(3);
 const score = ref(0);
 const game = ref(null);
 const gameConfig = ref(null);
@@ -193,7 +193,7 @@ const initGame = () => {
         // restartGame();
         emit('confirmExit', { type: 2, area: props.currentGameArea });
       }
-    }, 5000)
+    }, 500)
   });
   setTimeout(() => {
     if (currentScene.value === 'start') {
@@ -373,7 +373,7 @@ class GameScene extends Phaser.Scene {
     //this.player = this.physics.add.sprite(clientObj.value.width / 2, clientObj.value.height - 100, 'playerAnim');
     this.player = this.physics.add.sprite(direction.value + 46, clientObj.value.height - 100, 'playerAnim');
     this.player.setCollideWorldBounds(true);
-    this.player.setScale(2.5);
+    this.player.setScale(2);
     this.player.lives = this.lives;
     this.player.setDepth(9);
 
@@ -496,7 +496,7 @@ class GameScene extends Phaser.Scene {
   spawnObstacle() {
     const x = Phaser.Math.Between(30, clientObj.value.width - 30);
     const obstacle = this.physics.add.sprite(x, -50, 'pile');
-    obstacle.setScale(2.5);
+    obstacle.setScale(2);
     // 降低速度(从原来的this.speed * this.acceleration * 10调整为)
     obstacle.setVelocityY(this.speed * this.acceleration * 12); // 速度减半
     obstacle.setDepth(8);
@@ -540,7 +540,7 @@ class GameScene extends Phaser.Scene {
     //   powerUp.type = 'broom';
     // }
 
-    powerUp.setScale(2.5);
+    powerUp.setScale(2);
     // 降低道具速度(从原来的this.speed * this.acceleration * 8调整为)
     powerUp.setVelocityY(this.speed * this.acceleration * 12); // 速度降低
     powerUp.setDepth(8);
@@ -703,7 +703,7 @@ class GameScene extends Phaser.Scene {
 
     // 创建球门
     this.goal = this.physics.add.sprite(clientObj.value.width / 2, 100, 'goal');
-    this.goal.setScale(2.5);
+    this.goal.setScale(2);
     this.goal.setImmovable(true);
     this.goal.setDepth(5);
 
@@ -1127,27 +1127,36 @@ class GameScene extends Phaser.Scene {
 
 // 游戏控制函数
 const startGame = () => {
-  currentScene.value = 'countdown';
-
-  // 倒计时
-  currentScene.value = 'countdown';
-  let count = 3;
-  const countdownInterval = setInterval(() => {
-    count--;
-    countdownNum.value = count;
-
-    if (count <= 0) {
-      clearInterval(countdownInterval);
-      currentScene.value = 'game';
-      // 通知游戏开始
-      if (game.value) {
-        const gameScene = game.value.scene.getScene('GameScene');
-        if (gameScene) {
-          gameScene.startGame();
-        }
-      }
+
+
+  // 倒计时  
+  // currentScene.value = 'countdown';
+  // let count = 3;
+  // const countdownInterval = setInterval(() => {
+  //   count--;
+  //   countdownNum.value = count;
+
+  //   if (count <= 0) {
+  //     clearInterval(countdownInterval);
+  //     currentScene.value = 'game';
+  //     // 通知游戏开始
+  //     if (game.value) {
+  //       const gameScene = game.value.scene.getScene('GameScene');
+  //       if (gameScene) {
+  //         gameScene.startGame();
+  //       }
+  //     }
+  //   }
+  // }, 1000);
+
+  currentScene.value = 'game';
+  // 通知游戏开始
+  if (game.value) {
+    const gameScene = game.value.scene.getScene('GameScene');
+    if (gameScene) {
+      gameScene.startGame();
     }
-  }, 1000);
+  }
 };
 
 const continueGame = () => {
@@ -1172,7 +1181,7 @@ const restartGame = () => {
   // 2. 重置全局状态
   score.value = 0;
   currentScene.value = 'start';
-  countdownNum.value = 3;
+  // countdownNum.value = 3;
 
   // 3. 初始化新游戏
   setTimeout(() => {

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

@@ -1616,7 +1616,7 @@ class PlayScene extends Phaser.Scene {
           console.log('游戏结束,返回首页');
           // this.scene.start('main');
           emit('confirmExit', { type: 2, area: props.currentGameArea });
-        }, 5000);
+        }, 500);
       }
     });
 

+ 30 - 3
src/views/game/index.vue

@@ -71,6 +71,7 @@
         </div>
       </div>
     </Transition>
+    <div class="resumeGame" v-if="resumeGame" @click="getResumeGame">继续游戏</div>
     <div class="close" v-if="start" @click="getExitGame"></div>
     <ActionConfirmWindow ref="actionConfirmRef" @confirmExit="getExitGame({ type: 1 })" @confirmStart="getStartGame">
     </ActionConfirmWindow>
@@ -111,8 +112,9 @@ const data = reactive<any>({
   currentGameArea: [],//当前游戏区
   start: false,//是否开始游戏
   areaStateList: [],//各游戏就绪状态
+  resumeGame: false,//游戏结束显示继续游戏
 });
-const { projectList, wsState, bodyposeState, deviceInfo, currentGame, currentGameArea, start, areaStateList } = toRefs(data);
+const { projectList, wsState, bodyposeState, deviceInfo, currentGame, currentGameArea, start, areaStateList, resumeGame } = toRefs(data);
 
 /**
  * 监听数据变化
@@ -125,8 +127,9 @@ watch(
       return item.gameover;
     })
     if (state) {
-      start.value = false;
-      actionConfirmRef.value.getOpen(currentGame.value, currentGameArea.value);
+      // start.value = false;
+      // actionConfirmRef.value.getOpen(currentGame.value, currentGameArea.value);
+      resumeGame.value = true;
     }
   },
   { deep: true }
@@ -302,8 +305,17 @@ const getExitGame = (data: any) => {
 const getStartGame = (data: any) => {
   areaStateList.value = data;
   start.value = true;
+  resumeGame.value = false;
 };
 
+/**
+ * 继续游戏
+ */
+const getResumeGame = () => {
+  resumeGame.value = false;
+  start.value = false;
+  actionConfirmRef.value.getOpen(currentGame.value, currentGameArea.value);
+};
 
 onBeforeMount(async () => {
   getInit();
@@ -507,6 +519,21 @@ $waiPadding: 6.51rem;
   margin-left: -1.6rem;
 }
 
+.resumeGame{
+  width: 10rem;
+  height: 3.2rem;
+  line-height: 3.2rem;
+  font-size: 1.8rem;
+  color: #000000;
+  text-align: center;
+  background-color: rgba(216, 216, 216, 0.8);
+  z-index: 991;
+  position: fixed;
+  bottom: calc(35px + 3.2rem + 25px) ;
+  left: 50%;
+  margin-left: -5rem;
+  cursor: pointer;
+}
 
 ::v-deep(.menu) {
   .swiper-horizontal {