I cant really find my answer after browsing (not a lot of topics on cocos2d with game center)
I currently have my sandbox game center set up and I am able to authenticate, but when I create the leaderboard it is launched sideways in portrait I assume. Tried rotating the view but nothing. My game runs only in landscape mode. I am running beta 3 0.99.5. Here is my code for reference.
tempVC = [[RootViewController alloc] init];
GKLeaderboardViewController *leaderboardController = [[[GKLeaderboardViewController alloc] init] autorelease];
if (leaderboardController != nil)
{
leaderboardController.leaderboardDelegate = self;
[[[CCDirector sharedDirector] openGLView] addSubview:tempVC.view];
[tempVC presentModalViewController:leaderboardController animated:YES];
}
Really would appreciate any help. Getting no response from the cocos2d board.
EDIT:
Fixed by changing auto-rotation to CCDirector. Furthermore, I had issues with losing multi-touch functionality after showing gamecenter. The dismissal for the board should use this:
[tempVC dismissModalViewControllerAnimated:YES];
[tempVC.view.superview removeFromSuperview];
=I had this problem and was tearing my hair out for days, but I eventually got it to work perfectly in landscape mode, no matter what way the user is holding the phone. It's a bit weird, and if anyone knows better please let me know!
1 - I have to have the view (of the controller which calls the leaderboard) in portrait, in my case done in IB
2 - It only works if you support the portrait orientation (even if it looks like landscape) -
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
3 - You then need to resize & rotate the leaderboard -
[self presentModalViewController: leaderboardController animated: YES];
leaderboardController.view.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0.0f));
leaderboardController.view.bounds = CGRectMake(0, 0, 480, 320);
leaderboardController.view.center = CGPointMake(240, 160);
4 - Hey presto! It's working fine. Hope it works for you too.
Fixed by changing auto-rotation to CCDirector. Furthermore, I had issues with losing multi-touch functionality after showing gamecenter. The dismissal for the board should use this:
[tempVC dismissModalViewControllerAnimated:YES];
[tempVC.view.superview removeFromSuperview];
if it might help, I have found that simply removing the GKLeaderboard from the superview is not really enough, so after you use
[tempVC.view.superview removeFromSuperview];
you should also use
[tempVC release];
Without this the GKLeaderboardViewController is doing some weird things, like after the second call it is not auto rotating itself in the view.
I hope it help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With