{"id":18271040,"url":"https://github.com/apendley/CCNodeRecursiveDispatch","last_synced_at":"2025-04-05T01:30:59.955Z","repository":{"id":1673157,"uuid":"2400105","full_name":"apendley/CCNodeRecursiveDispatch","owner":"apendley","description":"CCNode category to run code on all descendants of a node","archived":false,"fork":false,"pushed_at":"2011-10-21T18:39:46.000Z","size":736,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-05T11:53:18.584Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apendley.png","metadata":{"files":{"readme":"readme.txt","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-09-16T15:28:32.000Z","updated_at":"2013-10-06T18:00:07.000Z","dependencies_parsed_at":"2022-09-07T03:21:26.288Z","dependency_job_id":null,"html_url":"https://github.com/apendley/CCNodeRecursiveDispatch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apendley%2FCCNodeRecursiveDispatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apendley%2FCCNodeRecursiveDispatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apendley%2FCCNodeRecursiveDispatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apendley%2FCCNodeRecursiveDispatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apendley","download_url":"https://codeload.github.com/apendley/CCNodeRecursiveDispatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276043,"owners_count":20912286,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T11:39:02.325Z","updated_at":"2025-04-05T01:30:59.670Z","avatar_url":"https://github.com/apendley.png","language":"Objective-C","readme":"CCNode(RecursiveDispatch):\n\nRelevant Files:\nCCNode+RecursiveDispatch.h\nCCNode+RecursiveDispatch.m\n\nDescription:\nA category with methods to propagate actions or dispatch of functions/selectors/blocks to all descendants (i.e. children on children of children etc.) of a node\n\n\n\nex: Run a FadeIn action on self and all of it's descendants\n\n-(void)fadeIn\n{\n\tCCFadeIn* fadeIn = [CCFadeIn actionWithDuration:0.5f];\n\t[self runAction:fadeIn];\n\t\n\t// makes a copy of fadeIn and runs it on all descendants\n\t[self makeDescendantsRunAction:fadeIn];\n}\n\nex: Run a FadeIn action on descendants of self using a block\n\n-(void)fadeInDescendants:(float)duration\n{\n\t[self visitDescendantsUsingBlock:^(CCNode* n) {\n\t\t[n runAction:[CCFadeIn actionWithDuration:duration]];\n\t}];\n}\n\nex: Run a fade in action on descendants of self that conform to the CCRGBAProtocol using a block\n\n-(void)fadeInDescendents:(float)duration\n{\n\t[self visitDescendantsUsingBlock:^(CCNode* n) {\n\t\tif( [n conformsToProtocol:@protocol(CCRGBAProtocol)] )\n\t\t\t[n runAction:[CCFadeIn actionWithDuration:duration]];\n\t}];\n}\n\nex: Run a fade in action on self and descendants that conform to the CCRGBAProtocol using a c function predicate\n\nBOOL conformsToCCRGBAProtocol(CCNode* node)\n{\n\treturn [node conformsToProtocol:@protocol(CCRGBAProtocol)];\n}\n\nvoid fadeInSelfAndDescendants(float duration)\n{\n\tCCFadeIn* fadeIn = [CCFadeIn actionWithDuration:duration];\n\t[self runAction:fadeIn];\n\t[self makeDescendantsRunAction:fadeIn predicate:conformsToCCRGBAProtocol];\n}\n\nex: set opacity on self and all of descendents that conform to the CCRGBAProtocol using a block as a visitor\n-(void)setOpacityOnSelfAndDescendents:(opacity:(GLubyte)opacity\n{\n\tself.opacity = opacity;\n\t[self visitDescendantsUsingBlock:^(CCNode *n) {\n\t\tif( [n conformsToProtocol:@protocol(CCRGBAProtocol)] )\n\t\t\t[(CCNode\u003cCCRGBAProtocol\u003e*)n setOpacity:opacity];\n\t}];\n}\n\nex: set opacity on node and descendents that conform to the CCRGBAProtocol using using a c function as a visitor, and passing in the opacity via a NSNumber\n\nvoid setOpacityOnNode(CCNode* node, id object)\n{\n\tif( [node conformsToProtocol:@protocol(CCRGBAProtocol)] )\n\t\t[(CCNode\u003cCCRGBAProtocol\u003e*)node setOpacity:[object unsignedIntValue]];\n}\n\nvoid setOpacityOnNodeAndDescendants(CCNode\u003cRGBAProtocol\u003e* node, GLUbyte opacity)\n{\n\tnode.opacity = opacity;\n\t[node visitDescendants:setOpacityOnNode withObject:[NSNumber numberWithUnsignedInt:opacity]];\n}\n\nex: setting opacity on self and propagating opacity to descendants that conform to CCRGBAProtocol\n\n-(void)propagateOpacityToNode:(CCNode*)node\n{\n\tif( [node conformsToProtocol:@protocol(CCRGBAProtocol)] )\n\t\t[(CCNode\u003cCCRGBAProtocol\u003e*)node setOpacity:self.opacity];\n}\n\n-(void)setOpacityOnSelfAndDescendents:(GLubyte)opacity\n{\n\tself.opacity = opacity;\n\t[self visitDescendantsUsingTarget:self selector:@selector(propagateOpacityToNode:)];\n}\n\nex: overriding setOpacity: on subclassed node conforming to CCRGBAProtocol (e.g. CCSprite) and propagating own opacity to all descendants conforming to CCRGBAProtocol\n\n-(void)setOpacity:(GLubyte)opacity\n{\n\t[super setOpacity:opacity];\n\t\n\t[self visitDescendantsUsingBlock:^(CCNode *node) {\n\t\tif( [node conformsToProtocol:@protocol(CCRGBAProtocol)] )\n\t\t\t[(CCNode\u003cCCRGBAProtocol\u003e*)node setOpacity:opacity_];\n\t}];\n}\n\nex: create an aggregated bounding box using the bounding box of all of a node's descendents using a function as a visitor\n\nvoid mergeBoundingBox(CCNode* node, void* data)\n{\n\tCGRect* pRect = (CGRect*)data;\t\n\t*pRect = CGRectUnion(*pRect, node.boundingBox);\n}\n\n-(CGRect)aggregateBoundingBoxForNode:(CCNode*)node\n{\n\tCGRect boundingBox;\n\tboundingBox.origin = CGPointZero;\n\tboundingBox.size = node.contentSize;\n\t\n\t[node visitDescendants:mergeBoundingBox withData:\u0026boundingBox];\n\treturn boundingBox;\n}\n\nex: create an aggregated bounding box using the bounding box of all of a node's descendents using a block as a visitor\n\n-(CGRect)aggregateBoundingBoxForNode:(CCNode*)node\n{\n\t__block CGRect boundingBox;\n\tboundingBox.origin = CGPointZero;\n\tboundingBox.size = node.contentSize;\n\t\n\t[node visitDescendantsUsingBlock:^(CCNode* n) {\n\t\tboundingBox = CGRectUnion(boundingBox, n.boundingBox);\n\t}];\n\t\n\treturn boundingBox;\n}\n\nex: pause scheduling and actions for a node and all descendants using makeDescendantsPerformSelector\n\nvoid pauseNodeAndDescendants(CCNode* node)\n{\n\t[node pauseSchedulerAndActions];\n\t[node makeDescendantsPerformSelector:@selector(pauseSchedulerAndActions)];\n}\n\n-(void)someMemberFunction\n{\n\t[self pauseSchedulerAndActions];\n\t[self makeDescendantsPerformSelector:@selector(pauseSchedulerAndActions)];\n}\n\nex: overriding pauseSchedulerAndActions on subclassed node to propagate pause to all descendents\n\n-(void)pauseSchedulerAndActions\n{\n\t[super pauseSchedulerAndActions];\t\n\t[self makeDescendantsPerformSelector:@selector(pauseSchedulerAndActions)];\n}","funding_links":[],"categories":["etc"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapendley%2FCCNodeRecursiveDispatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapendley%2FCCNodeRecursiveDispatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapendley%2FCCNodeRecursiveDispatch/lists"}