1

我收到以下警告:

不兼容的指针类型将“MenuScene”发送到“uiviewcontroller”类型的参数

我想通过单击菜单场景中的此按钮从 Game Center 调用排行榜。

-(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];

 }

在最后一条车道上,我收到了警告

4

1 回答 1

1

你应该从根视图控制器呈现一个 ViewController,所以你应该这样做:

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

   UIViewController *vc = self.view.window.rootViewController;
   [[GameCenterHelper defaultHelper] showLeaderboardOnViewController:vc];
于 2014-03-25T18:01:26.573 回答