4

Here's a simple tween in Tween.js. A simple loop happens after an interval.

cjs.Tween.get(mySymbol).wait(50).to({x:10}).to({x:0});

Is there a way to make it repeat say 5 times after the interval, without repeating the interval?

By adding loop:true I can make it loop but the loop would include the wait().

cjs.Tween.get(mySymbol, {loop:true}).wait(50).to({x:10}).to({x:0});

Is there any way to add tweens to the timeline sequentially in Tween.js?

4

2 回答 2

7

格兰特斯金纳的回答:

cjs.Tween.get(ball).wait(1000).play(
    cjs.Tween.get(ball,{paused:true, loop:true})
    .to({x:450},1000)
    .to({x:50},1000)
  );
于 2013-05-21T10:50:15.710 回答
1

要循环 5 次,您可以使用回调:

var tl = new createjs.Timeline();

tl.addTween(createjs.Tween.get(mySymbol).wait(500).call(loop, [mySymbol, 0], this));

var i;
var loopMax = 5;

function loop(target, initI){

    if (initI != null) {
        i = initI;
    } else {
        i++
    }

    if (i < loopMax) createjs.Tween.get(target).to({x:450},1000).to({x:50},1000).call(loop, [target]);

}
于 2013-05-21T17:06:14.200 回答