Browse Source

日常开发

林旭祥 4 weeks ago
parent
commit
d5ed77796d
1 changed files with 31 additions and 29 deletions
  1. 31 29
      src/views/game/football.vue

+ 31 - 29
src/views/game/football.vue

@@ -1,8 +1,8 @@
 <template>
   <div class="game-container">
     <div id="gameCanvas" class="game-canvas"></div>
-    <canvas ref="canvasRef" :width="clientObj.width" :height="clientObj.height"
-      style="position:fixed;left: 0; top: 0; z-index: 999;"></canvas>
+    <!-- <canvas ref="canvasRef" :width="clientObj.width" :height="clientObj.height"
+      style="position:fixed;left: 0; top: 0; z-index: 999;"></canvas> -->
     <!-- 游戏启动界面 -->
     <div v-if="currentScene === 'start'" class="gamestart">
       <img v-if="currentScene === 'start'" src="/static/images/football/game_start.jpg" class="start_bg" />
@@ -21,10 +21,10 @@
               <span class="daoju_1"></span>
               <p>每收集一个,生命值+1;触碰障碍物,生命可再复活。</p>
             </div>
-            <div class="daoju_item">
+            <!-- <div class="daoju_item">
               <span class="daoju_2"></span>
               <p>每收集一个,能力值+1;扫除面前一切障碍,加速前进。</p>
-            </div>
+            </div> -->
             <div class="daoju_item">
               <span class="daoju_3"></span>
               <p>触碰锥桶,生命值-1;成功绕过一次分数+1。</p>
@@ -111,7 +111,7 @@ const gameAssets = {
     { key: 'playerShoot', url: 'static/images/football/QiuyuanShooting.png' },
     { key: 'pile', url: 'static/images/football/Pile.png' },
     { key: 'jersey', url: 'static/images/football/Jersey.png' },
-    { key: 'broom', url: 'static/images/football/Broom.png' },
+    // { key: 'broom', url: 'static/images/football/Broom.png' },
     { key: 'goalkeeper', url: 'static/images/football/Goalkeeper.png' },
     { key: 'goal', url: 'static/images/football/Goal.png' },
     { key: 'ball', url: 'static/images/football/Ball.png' },
@@ -329,7 +329,7 @@ class GameScene extends Phaser.Scene {
     this.obstacleTimer = null; // 新增:初始化障碍物计时器
     this.obstacleEvent = null;
     this.jerseyEvent = null;
-    this.broomEvent = null;
+    // this.broomEvent = null;
     this.shootTimeout = null; // 射门超时计时器
     this.shootTimeLeft = 15; // 剩余射门时间
     this.shootTimerText = null; // 倒计时显示文本
@@ -434,7 +434,7 @@ class GameScene extends Phaser.Scene {
     if (this.timer) this.timer.remove();
     if (this.obstacleEvent) this.obstacleEvent.remove();
     if (this.jerseyEvent) this.jerseyEvent.remove();
-    if (this.broomEvent) this.broomEvent.remove();
+    // if (this.broomEvent) this.broomEvent.remove();
 
     // 重新开始生成障碍物和计时
     this.startSpawning();
@@ -461,10 +461,10 @@ class GameScene extends Phaser.Scene {
       this.jerseyEvent.remove();
       this.jerseyEvent = null; // 置空引用
     }
-    if (this.broomEvent) {
-      this.broomEvent.remove();
-      this.broomEvent = null; // 置空引用
-    }
+    // if (this.broomEvent) {
+    //   this.broomEvent.remove();
+    //   this.broomEvent = null; // 置空引用
+    // }
 
     // 重新创建事件(使用安全的场景上下文)
     this.obstacleEvent = this.time.addEvent({
@@ -477,11 +477,11 @@ class GameScene extends Phaser.Scene {
       callback: () => { if (this.gameActive) this.spawnPowerUp('jersey'); },
       loop: true
     });
-    this.broomEvent = this.time.addEvent({
-      delay: 8000,
-      callback: () => { if (this.gameActive) this.spawnPowerUp('broom'); },
-      loop: true
-    });
+    // this.broomEvent = this.time.addEvent({
+    //   delay: 8000,
+    //   callback: () => { if (this.gameActive) this.spawnPowerUp('broom'); },
+    //   loop: true
+    // });
 
     // 新增:立即生成第一个障碍物,确保倒计时结束后立即出现
     this.spawnObstacle();
@@ -528,10 +528,11 @@ class GameScene extends Phaser.Scene {
     if (type === 'jersey') {
       powerUp = this.physics.add.sprite(x, -50, 'jersey');
       powerUp.type = 'jersey';
-    } else if (type === 'broom') {
-      powerUp = this.physics.add.sprite(x, -50, 'broom');
-      powerUp.type = 'broom';
     }
+    // else if (type === 'broom') {
+    //   powerUp = this.physics.add.sprite(x, -50, 'broom');
+    //   powerUp.type = 'broom';
+    // }
 
     powerUp.setScale(0.7);
     // 降低道具速度(从原来的this.speed * this.acceleration * 8调整为)
@@ -595,10 +596,11 @@ class GameScene extends Phaser.Scene {
         this.lives = player.lives;
         this.livesText.setText(`生命: ${this.lives}`);
       }
-    } else if (powerUp.type === 'broom') {
-      // 激活超级状态
-      this.activateSuperMode();
     }
+    // else if (powerUp.type === 'broom') {
+    //   // 激活超级状态
+    //   this.activateSuperMode();
+    // }
 
     // 销毁道具
     powerUp.destroy();
@@ -682,7 +684,7 @@ enterShootingMode() {
   // 停止所有生成事件
   if (this.obstacleEvent) this.obstacleEvent.remove();
   if (this.jerseyEvent) this.jerseyEvent.remove();
-  if (this.broomEvent) this.broomEvent.remove();
+  // if (this.broomEvent) this.broomEvent.remove();
 
   // 清除现有障碍物和道具
   this.obstacles.forEach(obs => obs.destroy());
@@ -1002,11 +1004,11 @@ resetToRunningScene() {
       this.jerseyEvent = null;
     }
 
-    if (this.broomEvent) {
-      this.broomEvent.remove();
-      this.broomEvent.destroy();
-      this.broomEvent = null;
-    }
+    // if (this.broomEvent) {
+    //   this.broomEvent.remove();
+    //   this.broomEvent.destroy();
+    //   this.broomEvent = null;
+    // }
 
     // 4. 清除所有可能残留的计时器
     this.time.removeAllEvents();
@@ -1099,7 +1101,7 @@ resetToRunningScene() {
     if (this.timer) this.timer.remove();
     if (this.obstacleEvent) this.obstacleEvent.remove();
     if (this.jerseyEvent) this.jerseyEvent.remove();
-    if (this.broomEvent) this.broomEvent.remove();
+    // if (this.broomEvent) this.broomEvent.remove();
 
     // 移除输入监听
     this.input.keyboard.off('keydown-SPACE', this.shootBall, this);