在easelJs中检测点击舞台的空部分

Detecting click on empty part of the stage in easelJs

本文关键字:舞台 空部 easelJs 检测      更新时间:2023-09-26

我有一个问题检测鼠标点击/触摸舞台的空白部分。这是我的设置:

stage = new createjs.Stage(canvas);
stage.addChild(exportRoot);
stage.addEventListener('click', onStageClicked);
function onStageClicked(event) {
  console.log('event.currentTarget: ', event.currentTarget);
  console.log('event.target: ', event.target);
  console.log('event.target.parent: ', event.target.parent);
};

我只得到登录控制台当一些形状或图像是在舞台上被点击,但不是当舞台的实际空部分被点击。我如何检测点击舞台/画布的空部分?

tnx

卢卡

使用'stagemousedown'或'stagemouseup'事件。我把下面的代码从这里有EaselJS文档:http://www.createjs.com/tutorials/Mouse%20Interaction/

stage.on("stagemousedown", function(evt) {
    alert("the canvas was clicked at "+evt.stageX+","+evt.stageY);
})