Node* Utils::findChild(Node* parent, char* path)
{
std::vector<char*> strings;
const char *sep = "./-"; //可按多个字符来分割
char *p;
char src[100];
strcpy(src, path); // char* 没有开启足够的空间,所以用数组代替
p = strtok(src, sep); //分割函数,快速分割
while (p) {
strings.push_back(p);
p = strtok(NULL, sep); //持续分割
}
Node* pNode = parent;
for (char* name : strings)
{
pNode = pNode->getChildByName(name);
}
return pNode;
}
cocos2dx使用字符串切割便捷找到子孩子
猜你喜欢
转载自blog.csdn.net/piyixia/article/details/88704340
今日推荐
周排行