|
#1
|
|||
|
|||
|
I'm having trouble getting the leaderboards to show up in my game, short of my initial login, i have no idea if gamecenter is cooperating with my code. I prompt the leaderboards using a touch detect on some text, ala...
Quote:
Quote:
Quote:
Can anyone help? Or is there an existing example other than GKTapper? |
|
#2
|
|||
|
|||
|
I think you are missing the leaderboardViewControllerDidFinish: method. One implementation (that I haven't checked) could be the following, although I had found one-liners as well:
-(void)leaderboardViewControllerDidFinish GKLeader boardViewController*)viewController{CGRect frame = viewController.view.frame; [UIView beginAnimations:@"curldoup" context:nil]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:.5]; [UIView setAnimationDidStopSelector: @selector(animationDidStop:finished:context ];frame.origin.y = 480; viewController.view.frame = frame; [UIView commitAnimations]; } |
|
#3
|
||||
|
||||
|
My guess would be that you are just missing the required delegate template in the .h header:
Code:
@interface MyVC : UIViewController <GKLeaderboardViewControllerDelegate> {
}
|
|
#4
|
||||
|
||||
|
You can't pop a UIViewController directly from a CCLayer, you need to do it from within the context of another UIViewController.
First, expose your RootViewController as a property from your AppDelegate: @property (nonatomic, retain) RootViewController *viewController; Then, import your AppDelegate in your CCLayer.h file. Next: GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init]; leaderboardController.leaderboardDelegate = self; AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; RootViewController *vCont = appDelegate.viewController; [vCont presentModalViewController:leaderboardController animated:YES]; [leaderboardController release]; |
|
#5
|
|||
|
|||
|
If i understand correctly, the leaderboard must be popped from a UIViewController?
|
|
#6
|
||||
|
||||
|
Correct. It's just like popping a modal view controller in UIKit.
There are a number of people who have written sample code for this and suggest using a temporary view controller, but I prefer to do this against my app's root view controller as that seems to yield better results when dealing with orientation changes. |
|
#7
|
|||
|
|||
|
I had very similar issue, but I found a simple solution, like this:
HighscoreScene.h: Code:
@interface HighscoreScene : BaseScene <GKLeaderboardViewControllerDelegate>
{
(...)
}
(...)
- (void) showLeaderboard;
- (void) leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)leaderboardVC;
(...)
HighscoreScene.m: Code:
- (void) showLeaderboard
{
UIWindow* window = [UIApplication sharedApplication].keyWindow;
GKLeaderboardViewController *leaderboardVC = [[GKLeaderboardViewController alloc] init];
if (leaderboardVC != nil)
{
leaderboardVC.leaderboardDelegate = self;
UIViewController *vc = [[UIViewController alloc] init];
[window addSubview: vc.view];
[vc presentModalViewController: leaderboardVC animated: YES];
}
}
- (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)leaderboardVC
{
[leaderboardVC dismissModalViewControllerAnimated:YES];
[leaderboardVC.view.superview removeFromSuperview];
[leaderboardVC release];
}
-=Agnes=- |
![]() |
| Thread Tools | |
| Display Modes | |
|
|