Question

I got the following Warning:

Incompatible pointer types sending 'MenuScene' to parameter of type 'uiviewcontroller'

I want to call the leaderboard from Game Center by klick on this button in my menu scene.

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

 UITouch *touch = [touches anyObject];
 CGPoint location = [touch locationInNode: self];

 SKNode *node = [self nodeAtPoint:location];

 if ([node.name isEqualToString:@"playButton"]) {
    SKTransition *transition = [SKTransition fadeWithDuration:0.5];

   MyScene *gameScene = [[MyScene alloc]initWithSize:CGSizeMake(self.size.width, self.size.height)];

    [self.scene.view presentScene:gameScene transition:transition];

 } else if ([node.name isEqualToString:@"leaderboardButton"]) {

     [[GameCenterHelper defaultHelper] showLeaderboardOnViewController:self];

 }

at this last lane, i got the warning

Was it helpful?

Solution

you should present a ViewController from root view controller, so you should do:

 if ([node.name isEqualToString:@"leaderboardButton"]) {

   UIViewController *vc = self.view.window.rootViewController;
   [[GameCenterHelper defaultHelper] showLeaderboardOnViewController:vc];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top