在这个例子中,预期的结果是让圆先淡出然后淡入。这适用于链接。片段中的注释行
createjs.Tween.get(circle).wait(0).to({alpha:0.1},2000).wait(2000).to({alpha:1},2000)
如果我将它们分成对同一对象的 2 个单独的调用,它将不起作用。回调不是一种选择,因为在淡入和淡出圆之间可能有其他孩子的补间。
Tweenjs 似乎覆盖了所有其他以前的属性更改并只保留最后一个。对此有何建议?
<!DOCTYPE html>
<html>
<head>
<title>TweenJS: Canvas Tweening Example</title>
<script type="text/javascript" src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>
<script id="editable">
function init() {
stage = new createjs.Stage("canvas1");
var timeline=new createjs.Timeline();
var circle = new createjs.Shape();
circle.graphics.beginFill("#FF0000").drawCircle(50, 50, 50);
stage.addChild(circle);
timeline.addTween(
//circle should fadeTo 0.1 then back to 1
//createjs.Tween.get(circle).wait(0).to({alpha:0.1},2000).wait(2000).to({alpha:1},2000) //works
createjs.Tween.get(circle).wait(0).to({alpha:0.1},2000), //this tween is ignore
createjs.Tween.get(circle).wait(2000).to({alpha:1},2000) //only this tween fires
)
timeline.setPaused(false);
createjs.Ticker.setFPS(20);
createjs.Ticker.addEventListener("tick", stage);
}
</script>
</head>
<body onload="init();">
<canvas id="canvas1" width="960" height="350"></canvas>
</body>
</html>