Tween multiple blobs in KineticJs

自古美人都是妖i 提交于 2019-12-13 05:05:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!