From 34a321147d04fd5cf36bc806d779441ddb9aec2c Mon Sep 17 00:00:00 2001 From: "COMPUTER\\EDY" <249929363@qq.com> Date: Wed, 15 Oct 2025 16:16:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E6=9E=81=E9=80=9F?= =?UTF-8?q?=E8=BF=9E=E7=BB=AD=E9=80=9A=E8=BF=87=E5=BC=80=E5=85=B3=E9=97=A8?= =?UTF-8?q?BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Scene/GameScene.fire | 2 +- assets/Script/Wall.ts | 30 ++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/assets/Scene/GameScene.fire b/assets/Scene/GameScene.fire index 6681481..6876cdd 100644 --- a/assets/Scene/GameScene.fire +++ b/assets/Scene/GameScene.fire @@ -17581,7 +17581,7 @@ "_srcBlendFactor": 770, "_dstBlendFactor": 771, "_spriteFrame": { - "__uuid__": "b51c6577-3f31-4777-bf4a-6bfad58f0612" + "__uuid__": "ab9b1a6d-9c1b-4d87-ba50-43dbe414eb7f" }, "_type": 0, "_sizeMode": 1, diff --git a/assets/Script/Wall.ts b/assets/Script/Wall.ts index b960633..ad17960 100644 --- a/assets/Script/Wall.ts +++ b/assets/Script/Wall.ts @@ -112,6 +112,8 @@ export default class Wall extends cc.Component { open: boolean; freezeNumber: number; num: number; + leftTween: any; + rightTween: any; // LIFE-CYCLE CALLBACKS: @@ -290,21 +292,45 @@ export default class Wall extends cc.Component { } + // 停止之前的动画 + if (this.leftTween) { + this.leftTween.stop(); + this.leftTween = null; + } + if (this.rightTween) { + this.rightTween.stop(); + this.rightTween = null; + } + if (this.open == true) { + if (this.openNode.children[0].scaleX < 1 && this.openNode.children[0].scaleX > 0.01) { + this.openNode.children[0].scaleX = 1; + } + } + else { + if (this.openNode.children[0].scaleX < 1 && this.openNode.children[0].scaleX > 0.01) { + this.openNode.children[0].scaleX = 0.01; + } + } + + let fill = this.openNode.children[0].scaleX == 1 ? 0.01 : 1; if (this.openNode.children[0].scaleX < 0) fill = -fill; // console.log("目标",fill); - cc.tween(this.openNode.children[0]) + // 存储动画实例以便后续停止 + this.leftTween = cc.tween(this.openNode.children[0]) .to(0.3, { scaleX: this.openNode.children[0].scaleX < 0 ? -fill : fill }) .call(() => { // console.log("左边完成"); + this.leftTween = null; // 动画完成后清除引用 }) .start(); - cc.tween(this.openNode.children[1]) + this.rightTween = cc.tween(this.openNode.children[1]) .to(0.3, { scaleX: this.openNode.children[1].scaleX < 0 ? -fill : fill }) .call(() => { // console.log("右边完成"); + this.rightTween = null; // 动画完成后清除引用 }) .start(); }