我收到了以下警告:
不兼容的指针类型发送' 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];
}
在最后一个车道上,我收到了警告
答案 0 :(得分:1)
你应该从根视图控制器呈现一个ViewController,所以你应该这样做:
if ([node.name isEqualToString:@"leaderboardButton"]) {
UIViewController *vc = self.view.window.rootViewController;
[[GameCenterHelper defaultHelper] showLeaderboardOnViewController:vc];