Question

In my cocos2d project a helper method of mine is :

-(CCMenuItem *) itemForTouch: (UITouch *) touch
{
    CGPoint touchLocation = [touch locationInView: [touch view]];
    touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation];

    CCMenuItem* item;
    CCARRAY_FOREACH(children_, item)
    {
        // ignore invisible and disabled items: issue #779, #866
        if ( [item visible] && [item isEnabled] ) {

            CGPoint local = [item convertToNodeSpace:touchLocation];
            CGRect r = [item rect];
            r.origin = CGPointZero;

            if( CGRectContainsPoint( r, local ) )
                return item;
        }
    }
    return nil;
}

The code works however I keep getting the error "use of undeclared identifier children_; did you mean children and I get this for all of my variables with a "" after the word. Is this an xcode 'issue' or something I can put in my xcode project to prevent me from getting this error or does it have to do with my version of xcode?

Thank you for any help you can provide me on this error! :)

Thanks! John

Was it helpful?

Solution

I assume this is either code from an earlier version of cocos2d, or you've upgraded cocos2d in your project. The names of (most) ivars was changed from trailing underscore suffix to leading underscore suffix, as is standard in Objective-C.

So the correct use is:

_children
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top