kineticjs旋转到鼠标位置

时间:2013-06-27 08:21:18

标签: rotation kineticjs mouse-position

我试图补间到鼠标位置,但它没有聚焦鼠标。它走到一边。 有人看到了失败吗?

function tweenRotate2(layer) {

      for(var n = 0; n < layer.getChildren().length; n++) {
      var shape = layer.getChildren()[n];
      var stage = shape.getStage();
      var mousePos = stage.getMousePosition();


      var x =  mousePos.x - shape.getPosition().x;
      var y = mousePos.y -shape.getPosition().y ;
      var degree = Math.PI + Math.atan(y/x);


      new Kinetic.Tween({
        node: shape, 
        rotation: degree,
        easing: Kinetic.Easings.EaseInOut,
        duration:1,
      }).play();


    }
  }

0 个答案:

没有答案