【问题标题】:Pixi js mouse events for top most sprite onlyPixi js 鼠标事件仅适用于最上面的精灵
【发布时间】:2015-07-28 16:13:22
【问题描述】:

我注意到在 pixi.js 版本 1.3 中,如本例所示,堆叠精灵,然后单击并拖动只会拖动最顶部的精灵。

    bunny.mousedown = bunny.touchstart = function(data)
    {
//      data.originalEvent.preventDefault()
        // store a refference to the data
        // The reason for this is because of multitouch
        // we want to track the movement of this particular touch
        this.data = data;
        this.alpha = 0.9;
        this.dragging = true;
        this.sx = this.data.getLocalPosition(bunny).x * bunny.scale.x;
        this.sy = this.data.getLocalPosition(bunny).y * bunny.scale.y;
    };

http://jsfiddle.net/dirkk0/cXfpq/

在 3.0.3 版本中,如本例所示,相同的代码导致鼠标下的所有精灵都被拖动。

http://jsfiddle.net/9tnaa31z/5/

有没有办法只获取最顶部的精灵或获取所有精灵的列表(按渲染顺序)?

【问题讨论】:

  • 为什么要更改我的标签? pixi 是 webgl 和 canvas 的东西,而不仅仅是 javascript

标签: javascript sprite pixi.js


【解决方案1】:

我认为 PIXI3.0.3 版本可能存在错误。我刚刚使用最新的 3.0.5 进行了尝试,它按预期工作,即它只拖动最顶部的Sprite

用这个latest version of Pixi.js 更新你的小提琴中的外部资源,它应该可以工作。

参考:https://cdnjs.com/libraries/pixi.js

【讨论】:

  • 我也在 3.0.5 发布后立即尝试了它,它按预期工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-10
  • 2021-05-17
  • 2020-03-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多