[]阻止点击穿透问题

弹出一个层,点击层下面的骰子会触发事件。
TIM图片20180601165853.png

代码如下:
 骰子的点击事件代码:
this.items.shaizi.on("click", this, function(e) {
e.stopPropagation();
if(!Game.runing) {
Game.runing = true;
Game.stepNum = Math.floor(Math.random() * 6) + 1;
console.log(Game.stepNum)
Animate.role(Game.stepNum);
}
},[this.items.shaizi]);
 弹层的代码:
this.prizeAlertLayer = new Sprite();
this.prizeAlertLayer.zOrder = 90;
this.prizeAlertLayer.size(W, H);
 
let bg = new Sprite();
bg.alpha = 0.8;
bg.graphics.drawRect(0,0,W,H,"#000000");
this.prizeAlertLayer.addChild(bg);
this.prizeAlertLayer.addChild(Main.items["prizeinfo"]);
Laya.stage.addChild(this.prizeAlertLayer);
 
this.prizeAlertLayer.visible = false;
已邀请:

技术A恒

赞同来自:

添加个image图层,设置mouseThrough

LAYA_AIR

赞同来自:

这个楼主怎么解决的?我也是draw个Sprite覆盖在上面,不起作用。

游戏开发-程住气

赞同来自:

成功了。我的设置如图。
一定要将disable\mouseenable设置为false,,而不能选择默认。
不知道是不是坑,laya用的贼难受。
 

第七天堂

赞同来自:

弹窗 mouseThrough = true
 
首先你得确保 在 弹窗图像(Image 或者 Sprite )节点
 
mouseEnabled = true;//touch 启用  不启用 屏蔽不生效
mouseThrough = false;//屏蔽事件
 
 

installe

赞同来自:

改引擎底层,增加一个判断。没啥问题就凑合着用吧

要回复问题请先

商务合作
商务合作