views:

242

answers:

2

Hey everyone,

So i'm trying to use GameKit along with Cocos2D so that when a user clicks on the multiplayer menu item it will display the GKPeerPickerController. I'm however, running into some snags. It doesn't seem to want to compile. However, it doesn't give me an error inside of the code that's in my selector. Anyways here's the code...

    @implementation GameOverLayer
- (id) init 
{
    self = [super init];
    if (self != nil) 
    {
        [CCMenuItemFont setFontSize:20];
        [CCMenuItemFont setFontName:@"Helvetica"];
        CCMenuItem *start = [CCMenuItemFont itemFromString:@"Play Again!" target:self selector:@selector(startGame:)];
        CCMenuItem *connect = [CCMenuItemFont itemFromString:@"Multiplayer" target:self selector:@selector(connect:)];
        CCMenu *menu = [CCMenu menuWithItems:start,connect, nil];
        [menu alignItemsVertically];
        [self addChild:menu];
    }
    return self;
}
-(void)startGame: (id)sender 
{
    [[CCDirector sharedDirector] replaceScene: [HelloWorld scene]];
}

-(void)connect: (id)sender
{
    GKPeerPickerController *peerPicker;
    peerPicker = [[GKPeerPickerController alloc] init];

    peerPicker.delegate = self;
    peerPicker.connectionTypesMask = GKPeerPickerConnectionTypeOnline | GKPeerPickerConnectionTypeNearby;

    [peerPicker show];
}
@end

The error message i'm getting is...

".obj_class_name_GKPeerPickerController", referenced from:
Literal-Pointer@_OBJC@_cls_refs@GKPeerPickerController in GameOverScene.o
Symbol(s) not found
Collect2: id returned 1 exit status

Any ideas?

+2  A: 

Add the GameKit framework to your project, or if it's already there, make sure its target checkbox is checked.

tedge
That worked perfectly! Thank you!
Mark Hazlett
A: 

Thank you!I have got it!!!