[]阻止点击穿透问题
弹出一个层,点击层下面的骰子会触发事件。
代码如下:
骰子的点击事件代码:
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;
代码如下:
骰子的点击事件代码:
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;
没有找到相关结果
已邀请:
要回复问题请先登录
5 个回复
技术A恒
赞同来自:
LAYA_AIR
赞同来自:
游戏开发-程住气
赞同来自:
一定要将disable\mouseenable设置为false,,而不能选择默认。
不知道是不是坑,laya用的贼难受。
第七天堂
赞同来自:
首先你得确保 在 弹窗图像(Image 或者 Sprite )节点
mouseEnabled = true;//touch 启用 不启用 屏蔽不生效
mouseThrough = false;//屏蔽事件
installe
赞同来自: