如何从MenuScene中的SKNode Button调用排行榜

时间:2014-03-25 17:55:46

标签: ios iphone uiviewcontroller sprite-kit skscene

我收到了以下警告:

不兼容的指针类型发送' MenuScene'到#uiviewcontroller'

类型的参数

我想通过在我的菜单场景中点击此按钮来从游戏中心调用排行榜。

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

 }

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

1 个答案:

答案 0 :(得分:1)

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

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

   UIViewController *vc = self.view.window.rootViewController;
   [[GameCenterHelper defaultHelper] showLeaderboardOnViewController:vc];