Created
March 1, 2013 09:26
-
-
Save sdabet/5063493 to your computer and use it in GitHub Desktop.
getChildByTagRecursive for CCNode (from http://stackoverflow.com/questions/13309180/ccnode-recursive-getchildbytag)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface CCNode (getChildByTagRecursive) | |
-(CCNode*) getChildByTagRecursive:(int) tag; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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