[]半透明的矩形鼠标穿透问题


//画矩形
this.addLabel = new Sprite();
this.addLabel.graphics.drawRect(0, 730, 1440, 170, "#000000");
this.addLabel.alpha = 0.6;
this.addLabel.mousethrough = false;
this.addLabel.mouseEnabled = true;

sp.addChild(this.addLabel);
仍然能够点击下面的按钮.这个要怎么处理?

Laya_XS

赞同来自:

this.addLabel在手动一个size,因为你graphics画的是他自身,他画完宽高还是0,0,你如果要把他当做一个有宽高的对象,你需要手动设置下宽高!

taisss

赞同来自:

this.addLabel = new Sprite();
this.addLabel.graphics.drawRect(0, 730, 1440, 170, "#000000");
this.addLabel.width = 1440;
this.addLabel.height = 170;
this.addLabel.alpha = 0.6;
this.addLabel.mousethrough = false;
this.addLabel.mouseEnabled = true;
 
已经手动设置了,也是没有效果!

要回复问题请先

商务合作
商务合作