user2970795
user2970795

Reputation: 1

Cocos2d Unrecognized selector

I am working on a small game for I-pad touch as part of an assignment for a module in Games Programming. I am just handling the menu simple scene changes based on the buttons that are touched. It seems to be working fine, except for one specific scene chance.

I am getting the following error when trying touching the button that leads me to my options menu:

-[MainMenu goToOptions:]: unrecognized selector sent to instance 0xae2a1d0 * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MainMenu goToOptions:]: unrecognized selector sent to instance 0xae2a1d0'

And, this is the part of my code that is relevant to the crash, as well as the two functions that cause a scene change:

- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{

    for( UITouch *touch in touches ) {
        CGPoint location = [touch locationInView: [touch view]];

        location = [[CCDirector sharedDirector] convertToGL: location];

        CCActionInterval *actionInterval = [CCActionInterval actionWithDuration:0.1];


        if (CGRectContainsPoint([self.startButton boundingBox], location)) {
            [self.startButton setTexture:[[CCTextureCache sharedTextureCache] addImage:@"BeginButton.png"]];
            id actionCallFunc = [CCCallFunc actionWithTarget:self selector:@selector(goToInstructions:)];
            [self.background runAction: [CCSequence actions: actionInterval, actionCallFunc, nil]];
        }


        else if (CGRectContainsPoint([self.optionsButton boundingBox], location)) {
            [self.optionsButton setTexture:[[CCTextureCache sharedTextureCache] addImage:@"OptionsButton.png"]];
            id actionCallFunc = [CCCallFunc actionWithTarget:self selector:@selector(goToOptions:)];
            [self.background runAction: [CCSequence actions: actionInterval, actionCallFunc, nil]];
        }
    }
}


-(void) goToInstructions:(id) sender
{
    [[CCDirector sharedDirector] replaceScene: [CCTransitionSlideInL transitionWithDuration:2 scene:[InstructionsMenu node]]];
}


-(void) goToOpctions:(id) sender
{
    [[CCDirector sharedDirector] replaceScene: [CCTransitionFlipY transitionWithDuration:2 scene:[OptionsMenu node]]];
}
@end

Any idea what is the cause of the crash and how I could solve it?

Upvotes: 0

Views: 142

Answers (1)

YvesLeBorg
YvesLeBorg

Reputation: 9079

you have a typo in the method name , try :

-(void) goToOptions:(id) sender   {    // <--- TYPO here

Upvotes: 5

Related Questions