【 每日·槽】第1话 -- 论setEnabled和setVisible

http://www.cocoachina.com/bbs/read.php?tid=181496


【 每日·槽】第1话 -- 论setEnabled和setVisible 
每日槽,何弃疗? 
 
 
(Cocos2d-x3.4起 二者功能相同= =)// <-前面是版主留的话,时隔一年他们终于相(想)同(通)了 
 
最近setEnabled和setVisible这两个货坑了不少兄弟,所以今天先把这对妖怪拉出来,研究一下。 
 
本屌想做一个MessageBox,用来提示用户一些信息。当提示框显示的时候用户无法点击提示框后其他控件。 
MsgBox.ExportJson是我在编辑器里做的界面。蓝色的按钮是代码添加的。代码如下: 
 
        this._msgBox = ccs.GUIReader.getInstance().widgetFromJsonFile('MsgBox.ExportJson'); 
        this.addChild(this._msgBox); 
 
        var button2 = ccui.Button.create(); 
        button2.setTouchEnabled(true); 
        button2.loadTextures("res/animationbuttonnormal.png", "res/animationbuttonpressed.png", ""); 
        button2.setPosition(cc.p(200, 200)); 
 
        this.addChild(button2); 
 
如下图:现在所有按钮都可以点击,我想让弹出确认框的时候,后面蓝色的按钮无法响应。 
 

【 每日·槽】第1话 -- 论setEnabled和setVisible_第1张图片
  
 
让其他界面不响应事件嘛,简单,我首先想到了:setEnabled(false)。字面上看就是让widget不能用嘛。但。。。使用后的效果。。。。 
 
【 每日·槽】第1话 -- 论setEnabled和setVisible_第2张图片
  
 
小按钮你肿么了,小按钮你怎么没了!小按钮我不能没有你啊!

你可能感兴趣的:(【 每日·槽】第1话 -- 论setEnabled和setVisible)