Search code examples
kineticjs

kineticjs animate rotation onclick multiple times


I gettin stuck on some Kinetic.js thing. I want to rotate the shapes 45 degrees every time you click or tap, but now its only one time. I'm using tween to animated the rotation.

An Example here: jsfiddle

Can someone help me out

Thanks


Solution

  • Create the tween when you click on a node

    layer.on('click tap', function(evt) {
      evt.targetNode.tween = new Kinetic.Tween({
        node: evt.targetNode,
        duration: 0.3,
        rotationDeg: evt.targetNode.rotation()+45,
        easing: Kinetic.Easings.EaseOut
      });
      evt.targetNode.tween.play();
    }); 
    

    http://jsfiddle.net/JUu2Q/6/