English 中文(简体)
Cocos2d 游戏中心及前科
原标题:cocos2d game center and leaderboardViewControllerDidFinish

I have write the code like bellow

    - (void)leaderboard {
    GKLeaderboardViewController *leaderboardController = [[[GKLeaderboardViewController alloc] init] autorelease];
    currentLeaderBoard = kLeaderboardID;
    if (leaderboardController != NULL) 
    {
        leaderboardController.leaderboardDelegate = self; 
        leaderboardController.category = currentLeaderBoard;
        leaderboardController.timeScope = GKLeaderboardTimeScopeAllTime; 
        tempVC = [[UIViewController alloc] init];
        [[[[CCDirector sharedDirector] openGLView] window] addSubview:tempVC.view];
        [tempVC presentModalViewController:leaderboardController animated:YES];
    }
}


- (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
    [viewController dismissModalViewControllerAnimated:YES];
    [viewController release];
}

警告如下:

Assigning to  id<GKLeaderboardViewControllerDelegate>  from incompatible type  HelloWorldLayer * 

记录还显示:

warning: class  HelloWorldLayer  does not implement the  GKLeaderboardViewControllerDelegate  protocol

I count find out why it is. and even when the game center leader board goes out then the menu becomes disable. I count continue with the game everything becomes disable.

sorry for the post editing i have solved the second part of the problem by myself. I have shifted the leaderboard view in another view.

问题回答

您应进入班级接口,在已执行议定书清单中加入GKLeaderatViewControllerDelegate:

@interface HelloWorldLayer : CCLayer <GKLeaderboardViewControllerDelegate>

我无法理解的其余问题,你能否说几句?





相关问题
Cocos2d - Shooting Game Problem

everyone, I made a shooting game just like 1942(classic shooting game),but here s the question, FPS drops to 5~6 when the fighter shoot out a straight line of bullet,about 7~8 bullets in the screen,...

AtlasSpriteManager animation

I am using AtlasSpriteManager and AltasSprite to create frame by fram animation with 1 one file. I wanna write something that at first show a simple picture, without any animation and for example when ...

background moves together with image

I have 4 images and a background. I already about to animate the image to move accordingly. But the back ground is not moving. I am not sure how to make the background move accordingly to the movement ...

NSMutable array invalid after objectAtIndex

@implementation Level @synthesize doors, rooms; - (id) init { self = [super init]; if (self != nil) { rooms = [[NSMutableArray alloc] init]; doors = [[NSMutableArray alloc] init]; ...

How to subclass AtlasSpriteManager in Cocos2d?

I need to create some compound sprites that will all move and rotate together. Since it s possible to change the position and rotation of an AtlasSpriteManager I ve been trying to subclass so I can ...

热门标签