Tween的队列组织是不支持不同Target混编的吗...?

我本来打算这样…

for (let i = 0; i < 10; i++) {
    tween(this.node).delay(interval * i).sequence(
        this.tween_textRoll(i, noteIndex),
        this.tween_playNote(noteIndex),
        this.tween_luoboMove(noteIndex),
        this.tween_cookieMove(noteIndex),
        this.tween_cookieDrop(noteIndex),
    ).start();
}

甚至这样…

function play_Popup_Anime() {
    tween(this.$popup)
        .by(0.5, { eulerAngles: new Vec3(0, 0, -75) }, { easing: easing.sineIn })
        .then(this.tween_on_Popup_Full())
        .by(1, { eulerAngles: new Vec3(0, 0, 75) }, { easing: easing.sineOut })
        .start();
}

function tween_on_Popup_Full(interval = 0.5) {
    const tws: Tween<Node>[] = [];
    for (let i = 0; i < 10; i++) {
        tws.push(tween(this.node).delay(interval * i).sequence(
            this.tween_textRoll(i, noteIndex),
            this.tween_playNote(noteIndex),
            this.tween_luoboMove(noteIndex),
            this.tween_cookieMove(noteIndex),
            this.tween_cookieDrop(noteIndex),
        ).start());
    }
    return tween(this.node).parallel(...tws);
}

结果只能这样…

for (let i = 0; i < 10; i++) {
    setTimeout(() => {
        this.tween_textRoll(i, noteIndex).call(() =>
            this.tween_playNote(noteIndex).call(() =>
                this.tween_luoboMove(noteIndex).call(() =>
                    this.tween_cookieMove(noteIndex).call(() =>
                        this.tween_cookieDrop(noteIndex).call(() => { }
                        ).start()
                    ).start()
                ).start()
            ).start()
        ).start()
    }, interval * i * 1000);
}

不是吧大哥…

这样子的Tween是怎么能接受的…???

1赞

你好,引擎版本是?

3.3.2

感谢关注…我还以为会石沉大海了呢…

tween 从一开始就需要指定target ,或者说一个tween 只能对应一个 target

以下面为例

一个Node,其上有 UITransform 组件

你需要对这个节点同时做 position 和 width 的动画,并且在结束后回调

可能只能这样子写

tween(this.node)
  .to(0.24, {position: v3(100,100,0)})
  .start();
tween(this.node.getComponent(UITransform)!)
  .to(0.24, {width: 100})
  .call(() => {
    // 回调
  })
  .start();

我也是在这里感到非常疑惑,在实际项目中,肯定是有多动画串行和并行的,既然是多动画,就会存在多目标,如果sequence和parallel都不支持不同tween不同target的形式组合,这个存在的必要性就大大减低了。写起来逻辑会相当复杂。之前action都是可以的,串行并行都很好写,还有targetedAction这类的辅助,动画逻辑理清楚,写起来很方便。

你这例子压根就没搞懂tween的精髓…

大佬赐教一下~

不许你这么说魔猎手大佬~

确认了下,目前没对这种写法进行兼容。 :rofl:

randomTween() {
  return new Promise((resolve) => {
    tween(xxx)
      .to()
      .call(() => {
        resolve();
      })
      .start();
  })
}


async sequenceDemo() {
  await randomTween();
  await randomTween();
  await randomTween();
  await randomTween();

}


async parallelDemo() {
    await Promise.all([randomTween(), randomTween()]);
}

会有计划支持吗…
Node来来去去就那么几个属性能tween…
用途太窄了啊…

action没了,tween还是用不惯,感觉不够灵活

精髓就是完成需求
另外不许你说天煞魔猎手~

我第一次用的时候也是这种感觉,就觉得很奇葩,完全搞不懂官方的逻辑思维

真不好用,移动中渐隐渐显的动画很常见吧!结果是两个target,管理起来是真的麻烦;
在考虑要不要封装起来,类似原来的action,有大佬有好的方案么

3.8.5 中会根治此痛点:https://github.com/cocos/cocos-engine/pull/16979