循环参数未按预期工作

loop param not working as expected

我在舞台上有一个实例名称为 testShape 的剪辑。在第 1 帧中,我有以下代码:

createjs.Tween.get(this.testShape, {loop:true}).to({y:240}, 1000);

当我 运行 它按预期无限循环,但我想要的是它循环三次然后停止并触发 complete 事件。 文档说循环参数...

Indicates the number of times to loop. If set to -1, the tween will loop continuously.

这表明我应该能够设置 {loop: 3} 来实现我想要的结果,但 0 以外的任何数值只会导致它无限循环。

任何人都可以建议我做错了什么或如何在完成之前进行 n 次 Tween 循环吗?

大家干杯

看起来 TweenJS 0.6.2 和更早版本使用 Boolean value 作为 loops,所以虽然您可以将其设置为 truefalse,但您不能把它作为许多循环。如果设置为数字,则会转换为true.

createjs.Tween.get(obj, {loop:true}).to(…).to(…);

此行为已于 2017 年 9 月在 TweenJS 1.0.0 版中更新。

createjs.Tween.get(obj, {loop:3}).to(…).to(…);

很高兴您找到了解决方案:

I got it working in the end by making each tween set up the next as it completes.