在 Animate CC 2017 中使用画架拖放 [英] Drag and drop with easeljs in Animate CC 2017

查看:17
本文介绍了在 Animate CC 2017 中使用画架拖放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 Adob​​e Animate CC 2015.2 中的 HTML Canvas 项目在舞台上拖动一个影片剪辑,使用在 creatjs 鼠标交互教程.我在工作时在运行 OS X Yosemite 的 MacBook Pro 上执行此操作.

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.

这是我使用的代码,它运行良好.电影剪辑位于时间轴第一帧的舞台上,动作在同一帧中.movieClip 实例 (my_mc) 跟随鼠标移动 - 到目前为止一切顺利.

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;
});

但是,在 Animate CC 2017 中,在两个朋友的配备 Retina Display 并运行 macOS Sierra 的 MacBook Pro 上尝试完全相同的示例,导致鼠标位置和电影剪辑位置之间出现奇怪且明显的偏移.鼠标离舞台原点(0,0)越远,偏移越大.

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.

有谁知道为什么会发生这种情况或能想出解决方法吗?我已经尝试使用 globalToLocal 进行了一些修改,但这并不能解决问题.

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:

  • Animate CC 2017 中的一些变化导致了这个问题
  • 视网膜显示屏导致问题
  • macOS Sierra 导致问题

欢迎提出任何想法或解决方法.

Any thoughts or workarounds are welcome.

提前致谢,

戴夫

推荐答案

我想我已经解决了这个问题.无论操作系统和显示分辨率如何,以下内容似乎都适用于 Animate CC 2015.2 和 Animate CC 2017.

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;
});

我仍然需要弄清楚为什么在 Animate 2017 中需要进行更改,而在 Animate CC 2015.2 中不需要(抓头).

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).

谢谢,

戴夫

这篇关于在 Animate CC 2017 中使用画架拖放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆