@property([cc.Node])
cards: cc.Node[] = [];
private time: number = 0.3;
protected onLoad(): void {
this.initAni();
}
private initAni(): void {
for (let i = 0; i < this.cards.length; i++) {
const node = this.cards[i];
cc.tween(node)
.delay(i * this.time)
.to(0.15, { scaleX: 0 }, { easing: "quadInOut" })
.call(() => {
node.children[0].active = true;
node.children[1].active = false;
})
.to(0.15, { scaleX: 1 }, { easing: "quadInOut" })
.call(() => {
if (i === 1) {
// 也可以是触发一些事件什么来暂停该动画
this.pauseAllAni();
this.scheduleOnce(() => {
this.resumeAllAni();
}, 5);
}
})
.start();
}
}
private pauseAllAni(): void {
for (const e of this.cards) {
e.pauseAllActions();
}
}
private resumeAllAni(): void {
for (const e of this.cards) {
e.resumeAllActions();
}
}
写一个递归也可以吧