错误回报关于UIWidget getChildByTag函式

关于UIWidget getChildByTag函式
这实在太坑了
底下呼叫了CCUIHELPER> seekWidgetByTag(tag);
但是会包含自己阿…
这样跟函式名称完全有误阿建议改善

UIWidget* UIHelper::seekWidgetByTag(UIWidget* root, int tag)
{
if (!root)
{
return NULL;
}
if (root->getTag() == tag)
{
return root;
}
ccArray* arrayRootChildren = root->getChildren()->data;
int length = arrayRootChildren->num;
for (int i=0;i<length;i++)
{
UIWidget* child = (UIWidget*)(arrayRootChildren->arr*);
UIWidget* res = seekWidgetByTag(child,tag);
if (res != NULL)
{
return res;
}
}
return NULL;
}

建议修改方式:
*
*
UIWidget* UIHelper::seekWidgetByTag(UIWidget parentRoot, UIWidget root, int tag)
{
if (!root)
{
return NULL;
}
if (root->getTag() == tag)
{
return root;
}
ccArray* arrayRootChildren = root->getChildren()->data;
int length = arrayRootChildren->num;
for (int i=0;i<length;i++)
{
UIWidget* child = (UIWidget*)(arrayRootChildren->arr*);
UIWidget* res = seekWidgetByTag(*parentRoot,child,tag);

  •    if (res != NULL)
      {
          return res;
      }
    
    }
    return NULL;
    }

UIWidget UIWidget::getChildByTag(int tag)
{
return CCUIHELPER->seekWidgetByTag(this, this, tag);
}

getChildByName也有同样的问题
*
*

我今天也发现碰到这个问题了,太坑了

楼主您好,目前这两个查找方法确实是从根节点开始查找的,也就是所谓的seekWidgetByTag方法。建议在制作UI项目的时候就把tag或者那么做成唯一值

啥意思啊 没看懂说啥。。