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(); }