Game Development Reference
In-Depth Information
for (CCNode* node in children)
{
// check the node's children first
hit = [self hitTestNodeChildren:node.children point:point];
// abort search on first hit
if (hit)
{
break;
}
// scenes/layers are typically full screen, so do not hitTest them
if ([node isKindOfClass:sceneClass] || [node isKindOfClass:layerClass])
{
continue;
}
// check the node itself
hit = CGRectContainsPoint(node.boundingBox, point);
// abort search on first hit
if (hit)
{
break;
}
}
}
return hit;
}
...
@end
The first half of the for loop simply traverses deeper into the cocos2d node hierarchy
by calling the function recursively with the current node's children. If any of the re-
cursive calls have found a hit, the loop is aborted right there.
Search Nedrilad ::




Custom Search