如何在tween的sequence中动态添加序列

如何在tween的sequence中动态添加序列呢:比如这样:
for (var i = 0; i < children.length; i++) {
tweenArray.push(
cc.tween(this.node).to(1,{ position: children[i].position
})
)
}
this.tween = tween(this.node)
.sequence(
tweenArray//但这句子,报错
);

用then方法拼接

1赞

这样太不智能了吧,如果我不确定数量呢,或者要大量执行N个缓动呢,而且是依次执行

上面的函数是我项目里特定的用法,你的需求灵活使用then()方法组装就可以了。

动态添加action的需求,建议直接用cc.sequence(actionArr),这种方法,别用tween了

楼主的写法可不可以换成这样:
this.tween = cc.tween();
for (let i=0; i<children.length; ++i) {
this.tween.then(cc.tween().to(1,{position: children[i].position}))
}
使用的时候:
this.tween.clone(this.node).start();

没具体使用过then,只是猜测

差不多就是这意思。除了你最后的clone我没理解。

image
2.4.5我这么写没报错反正。

clone是个人习惯,如果是保存其他很多地方都在使用的时候我就是创建一份然后clone去使用

action被摒弃了啊,我用的3.2的,都已经没action了。。

最后,写成这样了:

        this.tweenPos = tween(this.Spherectrl)
        var children = this.nodeArray.children;

        //用for循环,来进行tween呢,或者动态改 to的状态

        for (let i = 0; i < children.length; ++i) {

            let pot = new Vec3(children[i].position.x, this.Spherectrl.position.y, children[i].position.z);

            this.tweenPos.then(tween().to(1, { position:pot }))

        }

        this.tweenPos.clone(this.Spherectrl).repeat(Infinity).start();

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。