cocostudio读取UI后,触摸或者按钮点击穿透问题。

1、必须把当前的UILayer的优先级设置为1,priority的数值越大,优先级越低
[cpp]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. m_uiLayer = UILayer::create();  
  2.     UIWidget *m_uiLayerWidget = GUIReader::shareReader()->widgetFromJsonFile(shopBlackPath"ui_layout_shop_black.json");  
  3.     CCAssert(m_uiLayerWidget, "");  
  4.     m_uiLayer->addWidget(m_uiLayerWidget);  
  5.     this->addChild(m_uiLayer, 1);  
  6.     m_uiLayer->setTouchPriority(1);  
2、必须把CCtableView里面的layer的优先级设置为2,。防止穿透点击tableView里面的按钮。
[cpp]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. CCTableViewCell* ShopBlackLayer::tableCellAtIndex(CCTableView *table, unsigned int idx)  
  2. {  
  3.     CCTableViewCell *cell = table->dequeueCell();  
  4.     if (!cell)   
  5.     {  
  6.         // the sprite  
  7.         cell = new CCTableViewCell();  
  8.         cell->autorelease();  
  9.     }  
  10.     else  
  11.     {cell->removeAllChildrenWithCleanup(true);}  
  12.   
  13.     UIWidget *widget = m_cellWidget->clone();  
  14.     widget->setTag(idx);  
  15.   
  16.     UILayer *layer = UILayer::create();  
  17.     layer->addWidget(widget);  
  18.     layer->setTouchPriority(2);  
  19.   
  20.     cell->addChild(layer);  
  21.     return cell;  
  22. }  

3、必须把Panel_top和Panel_bottom的渲染层级设置为0,而把其他需要接受点击的按钮的渲染层级设置为比Panel。这样就把屏蔽了tableview的点击穿透了。Panel_top设置为可交互。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值