在使用 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;
关于javascript - CreateJS - hitAreas 上的 d.mousedown.f 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29066238/