问题
How can I tween multiple blobs in Kinetic JS?
I can tween a blob using two set of points, but what about more than that? Here's what I have so far:
JS
setTimeout(function () {
for (var i = 0; i < blobPoints.length; i++) {
var tween = new Kinetic.Tween({
node: blob,
duration: .5,
points: blobPoints[i],
onFinish: function () {
//this is where I want to call next tween using next set of points
}
});
tween.play();
};
}, 300);
Complete demo here: http://jsfiddle.net/4KLf8/1/
If you notice, it tweens to the next set of points but very fast, it's even hard to see. I want it to complete the tween first before it calls the next set of points. I'm not quiet sure how to do that.
回答1:
function runTween(number) {
var tween = new Kinetic.Tween({
node: blob,
duration: .5,
points: blobPoints[number],
onFinish: function () {
var next = number+ 1;
if (blobPoints[next]) {
runTween(next);
}
}
});
tween.play();
}
setTimeout(function () {
runTween(0)
}, 300);
http://jsfiddle.net/4KLf8/3/
来源:https://stackoverflow.com/questions/22552372/tween-multiple-blobs-in-kineticjs