Browse Source

日常开发

林旭祥 1 month ago
parent
commit
5e4ba6e2c9
1 changed files with 22 additions and 0 deletions
  1. 22 0
      src/views/game/fruit.vue

+ 22 - 0
src/views/game/fruit.vue

@@ -613,6 +613,28 @@ class Bomb {
 
     // 开始执行第一个灯光动画
     playChainAnimations(0);
+
+  // 新增:在爆炸动画开始后立即隐藏炸弹,动画结束后销毁
+  this.sprite.visible = false; // 先隐藏视觉元素
+
+  // 在爆炸完成回调中销毁炸弹
+  const originalOnComplete = onComplete;
+  onComplete = () => {
+    // 销毁炸弹容器及其内部所有元素
+    if (this.sprite) {
+      this.sprite.destroy();
+    }
+    if (this.bombEmit) {
+      this.bombEmit.destroy();
+    }
+    if (this.bombSmoke) {
+      this.bombSmoke.destroy();
+    }
+    // 执行原有的完成回调
+    if (typeof originalOnComplete === 'function') {
+      originalOnComplete();
+    }
+  };
   }
   getSprite() {
     return this.sprite;