【问题标题】:Adobe Animate CC JavaScript: Mouse follower is not aligned when responsive is activeAdobe Animate CC JavaScript:响应处于活动状态时鼠标跟随器未对齐
【发布时间】:2017-02-15 19:46:41
【问题描述】:

我已经在 Adob​​e Animate CC 上创建了一个网站,我已经使用以下代码 sn-p 完成了鼠标跟随:

    this.stage.canvas.style.cursor = "none";
    this.mouseEnabled = true;
    this.addEventListener("tick", fl_CustomMouseCursor.bind(this));

function fl_CustomMouseCursor() {
    this.plus_mc.x = stage.mouseX;
    this.plus_mc.y = stage.mouseY;
    this.black_plus_mc.x = stage.mouseX;
    this.black_plus_mc.y = stage.mouseY;
}

当我选中使其在发布设置时响应时,追随者未与鼠标光标对齐,只有当我将光标放在浏览器左上角时它才会对齐,然后当我移动光标时它会变得很远。

【问题讨论】:

    标签: javascript adobe code-snippets


    【解决方案1】:

    我从 ClayUUID 的 Adob​​e 论坛中找到了解决方案:

    我用stage.scaleX和scaleY划分坐标。

    这是使页面响应并对齐光标跟随器的正确代码:

    this.stage.canvas.style.cursor = "none";
    this.mouseEnabled = true;
    this.addEventListener("tick", fl_CustomMouseCursor.bind(this));
    
    function fl_CustomMouseCursor() {
        this.plus_mc.x = stage.mouseX / stage.scaleX;
        this.plus_mc.y = stage.mouseY / stage.scaleY;
        this.black_plus_mc.x = stage.mouseX / stage.scaleX;
        this.black_plus_mc.y = stage.mouseY / stage.scaleY;
    }
    

    谢谢

    【讨论】:

      猜你喜欢
      • 2016-10-20
      • 2017-11-11
      • 2018-07-23
      • 2016-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-13
      相关资源
      最近更新 更多