CreateJS - d.mousedown.f hitAreas 错误

CreateJS - d.mousedown.f error on hitAreas

我在使用 CreateJS 编程时遇到了一个错误:

Unhandled exception at line 13, column 10113 in https://code.createjs.com/createjs-2014.12.12.min.js

0x800a138f - Runtime Error JavaScript code: Can not retrieve "matrix" properties for undefined or empty appeal

只有当我在图像中添加点击区域时才会出现此错误:

    function drawButton(e) {
        var button = new createjs.Bitmap(e.target);
        var newContainer = new createjs.Container();
        newContainer.addChild(button);
        var label = new createjs.Text("Next round", "20 px Arial", "#000");
        newContainer.addChild(label);
        button.hitArea = new createjs.Rectangle(0, 0, 100, 100);
        button.addEventListener("click", onClick);
        buttonContainer.addChild(newContainer);

        GameData.hudStage.update();
    }

去掉后:button.hitArea = new createjs.Rectangle(0, 0, 100, 100); bug没有出现。是库错误,还是我遗漏了什么?

hitArea 必须是 DisplayObject - 但您试图将 Rectangle 分配为 hitArea,这不是 DisplayObject ].如果您使用 Shape(或类似),代码应该按预期工作:

 var shape = new createjs.Shape();
 shape.graphics.beginFill("#000000").drawRect(0, 0, 100, 100);

 button.hitArea = shape;