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

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

问题描述

我一直在使用Adobe Animate CC 2015.2中的HTML Canvas项目来拖动舞台上的movieClip,使用 creatjs鼠标交互教程。我正在MacBook Pro上运行OS X Yosemite。



这是我使用的代码,它工作正常。 movieClip在时间线的第一帧的舞台上,动作在同一帧中。 movieClip实例(my_mc)跟随着鼠标左右 - 非常好。

  this.my_mc.on(pressmove,function(evt){
evt.currentTarget.x = evt .stageX;
evt.currentTarget.y = evt.stageY;
});然而,在两位朋友的MacBook Pro上,尝试使用Animate CC 2017完全相同的例子,在Retina Display上运行macOS Sierra导致鼠标的位置与movieClip的位置之间存在奇怪且显着的偏移。鼠标从舞台的原点(0,0)移开距离越远越大。



有谁知道为什么会发生这种情况,或者可以想到一个解决方法?我已经使用globalToLocal尝试了一些修改,但是这不能解决问题。

我能想到的三个主要原因是:
$ b $ ul

  • Animate CC 2017导致此问题

  • 视网膜显示器导致问题

  • macOS Sierra导致问题



    欢迎提供任何想法或解决方法。

    在此先感谢您,

    Dave

    解决方案

    我想我已经排序了这个问题。以下内容似乎可以在Animate CC 2015.2和Animate CC 2017上运行,无论操作系统和显示分辨率如何。

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

    在Animate 2017中,我仍然需要深入了解为什么需要进行更改,而不是Animate CC 2015.2(scratches head)。

    谢谢,

    Dave


    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

    解决方案

    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

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

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