【发布时间】:2016-08-27 00:39:36
【问题描述】:
我画了 2 个形状,一个在另一个之上。 getObjectsUnderPoint 函数只返回一个形状,即使该点是两个形状的一部分。我在上部形状的 addEventListener 处理程序中得到的要点。这是完整的jsfiddle example。
var stage;
function init() {
stage = new createjs.Stage("canvas");
var rect = new createjs.Shape();
rect.graphics.beginFill("#ff0000").drawRect(10, 10, 100, 100);
stage.addChild(rect);
var circle = new createjs.Shape();
circle.graphics.beginFill("#00ff00").drawCircle(60, 60, 40);
circle.addEventListener("click", onClick);
stage.addChild(circle);
stage.update();
}
function onClick(e) {
// the length should be 2: circle + rectangle, but is only 1 ???
alert(stage.getObjectsUnderPoint(e.stageX, e.stageY).length);
}
【问题讨论】: