Dart StageXL 在重叠精灵上激活鼠标事件

Dart StageXL activate mouse event on overlapping sprites

是否可以为两个精灵重叠调用鼠标事件?我曾尝试使用 getObjectsUnderPoint,但它似乎不起作用。

class Line extends Sprite
{
    int x;
    int y;
    int type;
    var tempLine = new Shape();
    bool isClicked = false;

    Line(int xPos, int yPos, int type)
    {
        this.x = xPos;
        this.y = yPos;
        this.type = type;

        if(type == 1)
        {
            graphics.beginPath();
            graphics.moveTo(x, y);
            graphics.lineTo(x+300, y);
            graphics.closePath();
            graphics.strokeColor(Color.LightGray,19);
            addEventListener(MouseEvent.CLICK, react);
            tempLine.graphics.beginPath();
            tempLine.moveTo(x,y);
            tempLine.graphics.lineTo(x+300,y);
            tempLine.graphics.closePath();
        }
        else if(type == 2)
        {
            graphics.beginPath();
            graphics.moveTo(x, y);
            graphics.lineTo(x, y+300);
            graphics.closePath();
            graphics.strokeColor(Color.LightGray,19);
            addEventListener(MouseEvent.CLICK, react);
            tempLine.graphics.beginPath();
            tempLine.moveTo(x,y);
            tempLine.graphics.lineTo(x,y+300);
            tempLine.graphics.closePath();
        }
        addChild(tempLine);
    }

    react(MouseEvent event)
    {
        Point tempPoint = new Point(event.localX, event.localY);
        graphics.strokeColor(Color.Black,19);
        isClicked = true;
        var subShape = getObjectsUnderPoint(tempPoint);
        for(Shape i in subShape)
        {
            i.parent.userData.isClicked = true;
        }
    }
}

我有两个 Line 重叠的对象,单击其中一个时,我希望两个对象的布尔值都为 true。我读到 getObjectsUnderPoint 没有 return 和 Sprite,这可能是问题所在吗?

MouseEvents 仅被分派到扩展 InteractiveObject class 的最顶层显示 object(这对所有 DisplayObjectContainer 和 Sprites 都是如此)。所以只有一个显示器 object 可以接收到 MouseEvent.CLICK 事件。你是对的,getObjectsUnderPoint 只做 return DisplayObjectContainers 的 children,但是 GitHub 存储库 (https://github.com/bp74/StageXL/issues/209) 上有一个未解决的问题正在谈论这个。 StageXL 的下一个版本(高于版本 0.13)可能会改变此行为。