Drag and drop with easeljs in Animate CC 2017

对着背影说爱祢 提交于 2019-12-01 09:26:12

问题


I've been using an HTML Canvas project in Adobe Animate CC 2015.2 to drag around a movieClip on the stage, using the method recommended in the creatjs Mouse Interaction Tutorial. I was doing this on a MacBook Pro running OS X Yosemite at work.

Here is the code I used and it worked fine. The movieClip is on the stage in the first frame of the timeline and the actions are in that same frame. The movieClip instance (my_mc) follows the mouse around - so far so good.

this.my_mc.on("pressmove", function(evt){
    evt.currentTarget.x = evt.stageX;
    evt.currentTarget.y = evt.stageY;
});

However, trying the exact same example in Animate CC 2017 on two friends' MacBook Pros with Retina Display running macOS Sierra, results in there being a strange and significant offset between the position of the mouse and the position of the movieClip. The offset is bigger the further away the mouse moves from the origin (0,0) of the stage.

Does anyone know why this is happening or can think of a workaround? I've tried a few modifications using globalToLocal, but this does not solve the problem.

The three main reasons I can think of are:

  • Some change in Animate CC 2017 is causing this problem
  • The Retina Display is causing the problem
  • macOS Sierra is causing the problem

Any thoughts or workarounds are welcome.

Thanks in advance,

Dave


回答1:


I think I've sorted the problem. The following seems to work on both Animate CC 2015.2 and Animate CC 2017 irrespective of OS and display resolution.

this.my_mc.on("pressmove", function(evt){
    var p = stage.globalToLocal(evt.stageX, evt.stageY);
    evt.currentTarget.x = p.x;
    evt.currentTarget.y = p.y;
});

I still have to get my head around why the change was necessary in Animate 2017 and not in Animate CC 2015.2 (scratches head).

Thanks,

Dave



来源:https://stackoverflow.com/questions/43413936/drag-and-drop-with-easeljs-in-animate-cc-2017

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