想创建一个遮章层,以屏蔽该层以下的触摸
所以我实现了一个遮章layer层:
var layer = cc.Layer.extend({
ctor:function () {
//////////////////////////////
// 1. super init first
this._super();
this._fixedPriority = -129
},
onEnter: function(){
this._super()
this.setColor(cc.color.BLACK)
this.setOpacity(155)
var listener = cc.EventListener.create({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouchs : true,
onTouchBegan:function(touch,event){
cc.log("1111111111111")
return true;
}
})
cc.eventManager.addListener(listener, this)
}
});
```
然后在app.js里添加如下代码:
//添加触摸
cc.eventManager.addListener(cc.EventListener.create({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouchs : true,
onTouchBegan:function(){
cc.log("22222222222222")
return true;
}
}),this)
var size = cc.winSize
var lay = new layer()
this.addChild(lay)
```
结果输出: 111111111111 2222222222222
事实应该输出111111111才对,因为上层开启了吞噬触屏。请教各位大神以及版主应该怎么解决呢?