新手求教,写了一个按节点顺序执行的动画,并且支持暂停的效果,看一下有什么问问题或者能优化的

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

写一个递归也可以吧