加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 19:44:51 所属栏目:百科 来源:网络整理
导读:1、必须把当前的UILayer的优先级设置为1,priority的数值越大,优先级越低 m_uiLayer = UILayer::create();UIWidget *m_uiLayerWidget = GUIReader::shareReader()-widgetFromJsonFile(shopBlackPath"ui_layout_shop_black.json");CCAssert(m_uiLayerWidget,"
1、必须把当前的UILayer的优先级设置为1,priority的数值越大,优先级越低
m_uiLayer = UILayer::create();
	UIWidget *m_uiLayerWidget = GUIReader::shareReader()->widgetFromJsonFile(shopBlackPath"ui_layout_shop_black.json");
	CCAssert(m_uiLayerWidget,"");
	m_uiLayer->addWidget(m_uiLayerWidget);
	this->addChild(m_uiLayer,1);
	m_uiLayer->setTouchPriority(1);
2、必须把CCtableView里面的layer的优先级设置为2,。防止穿透点击tableView里面的按钮。
CCTableViewCell* ShopBlackLayer::tableCellAtIndex(CCTableView *table,unsigned int idx)
{
	CCTableViewCell *cell = table->dequeueCell();
    if (!cell) 
	{
        // the sprite
		cell = new CCTableViewCell();
        cell->autorelease();
    }
    else
    {cell->removeAllChildrenWithCleanup(true);}

	UIWidget *widget = m_cellWidget->clone();
	widget->setTag(idx);

	UILayer *layer = UILayer::create();
	layer->addWidget(widget);
	layer->setTouchPriority(2);

	cell->addChild(layer);
    return cell;
}

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读