Skip to content

Instantly share code, notes, and snippets.

@sdabet
Created March 1, 2013 09:26
Show Gist options
  • Save sdabet/5063493 to your computer and use it in GitHub Desktop.
Save sdabet/5063493 to your computer and use it in GitHub Desktop.
@interface CCNode (getChildByTagRecursive)
-(CCNode*) getChildByTagRecursive:(int) tag;
@end
@implementation CCNode (getChildByTagRecursive)
-(CCNode*) getChildByTagRecursive:(int) tag {
CCNode* result = [self getChildByTag:tag];
if(result == nil) {
for(CCNode* child in [self children]) {
result = [child getChildByTagRecursive:tag];
if(result != nil) {
break;
}
}
}
return result;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment