修复 极速连续通过开关门BUG

This commit is contained in:
COMPUTER\EDY 2025-10-15 16:16:58 +08:00
parent 058cdfc88a
commit 34a321147d
2 changed files with 29 additions and 3 deletions

View File

@ -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,

View File

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