2014-03-25 39 views
1

打電話排行榜我得到了以下警告:如何從SKNode按鈕在MenuScene

不兼容的指針類型發送「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

你應該從根視圖控制器呈現視圖控制器,所以你應該做的:

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

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

WOWS謝謝伊拉里奧!你是最棒的!!謝謝:) – Mehmet63

+0

@ user3460981沒問題!你能接受我的回答嗎? ;-) – Ilario