cocostudio中怎么制作‘’模态‘’对话框,即屏蔽底层的触摸功能

如题,我用cocostudio制作了一个UI界面,有3个层容器:

层容器一:存放-------主背景(有一个’‘设置‘’按钮)。

层容器二:存放--------“对话框”。

现在我可以实现点击“设置”按钮后,弹出“对话框”。可是,弹出对话框后,底层仍然可以被点击。 但我想屏蔽掉底层的触摸功能。请问该如何做呢?

这个需要做一个layer,遮住下面,监听touch事件,return true即可,并且设置其touch优先级为-128.同时 设置弹出的对话框的touch优先级也-128,就可以了。

可以把代码列出来吗?我是菜鸟。谢谢啦

给你贴个JS版本的

wt.display.PopupLayer = cc.LayerColor.extend({

init:function() {

var color = cc.c4b(100, 100, 100, 100);

if(!this._super(color, 0, 0)){

wt.error("cannot create popup layer, init failed!");

return false;

}

this.stage = wt.display.stage;

this.ignoreAnchorPointForPosition(false);

this.setAnchorPoint(0.5,0.5);

this.setPosition(wt.winSize.width/2, wt.winSize.height/2);

//for jsb, will not work in jsb if not set content size

this.setContentSize(wt.winSize);

this.setTouchEnabled(true);

return true;

},

//wont invoke in jsb

registerWithTouchDispatcher:function(){

this.registerSuccess = true;

// 这里的触摸优先级设置为 -128 这保证了,屏蔽下方的触摸

// wt.log(">>>>>>>registerWithTouchDispatcher work!!!!");

cc.registerTargetedDelegate(-128,true,this);

},

onEnter:function(){

this._super();

if(!this.registerSuccess){//for jsb bug

this.registerSuccess = true;

this.registerWithTouchDispatcher();

}

},

//for jsb

onExit:function() {

this._super();

//we need do remove for jsb, may cause "js object has been unrooted" problem

if(this.registerSuccess) {

cc.unregisterTouchDelegate(this);

}

},

onTouchBegan:function(touch, event) {

// wt.log("wt.display.PopupLayer:onTouchBegan");

return true;

}

});

对于弹出框上面的 确定按钮 checkbox 怎么设置优先级?

我目前设置-129,但是没有按钮 checkbox没有响应