I try to move a circle to mouseposition on an ipad with this code:

    function CircleMovetoMouse(){
         var mousePos = stage.getMousePosition();
         var xpos = mousePos.x;
         var ypos = mousePos.y ;

          var circle1 = stage.get('#Circle1')[0];
           new Kinetic.Tween({
              node: circle1, 
              duration: 1,
              x: xpos , 
              y: ypos, 
              easing: Kinetic.Easings.EaseInOut
            }).play();

              $('#container').bind('click touchstart', function() {
                CircleMovetoMouse()
               });

works perfect on desktop but not on smartphone and ipad. I need it really badly so it would be really great if someone can help. thanks in advance.

有帮助吗?

解决方案

I think you need to use getTouchPosition() to get the touch coordinates. See the tutorial.

var touchPos = stage.getTouchPosition();

Also just FYI, the "click" equivalent for mobile events is "tap", not "touchstart".

$('#container').bind('click tap', function() {
  CircleMovetoMouse()
});

Touchstart <=> mousedown.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top