COCOS2D-iPhone – How to determine if the elves are in the layer

Sorry if this sounds trivial. I just didn’t get it. How can I determine if a particular sprite already exists in the layer? Basically, I need to check this before deciding whether to add it to the layer.
if ( [myNode.children indexOfObject:sprite] == NSNotFound) {

// you can add the code here

}

Sorry, if this sounds trivial. I just didn’t get it. How can I determine if a particular sprite already exists in the layer? Basically, I need to check this before deciding whether to add it to the layer.

if ([myNode.children indexOfObject:sprite] == NSNotFound) {

// you can add the code here

}

Leave a Comment

Your email address will not be published.