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设置为可交互。
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- xml – Ellipsize不工作在自定义listView内的textView
- ruby-on-rails – Docker – PG :: ConnectionBad
- cocos2d-x开发完iOS后改为Android遇到的一些问题
- 聚合数据iOS SDK 全国车辆违章 演示示例
- c# – GZipStream压缩问题(Lost Byte)
- 常用的正则表达式代码汇总
- cocos2d-x 坐标研究
- ruby-on-rails – Rails rspec devise =未定义的方法`authe
- Flex ExternalInterface 在 ActionScript 和 Flash Player
- ruby-on-rails – 动态命名空间控制器在Rails中具有回退功能