i used the code below to show the game center but if I rotate the iPhone nothing happen and the Leaderboard will be upside-down (not respond for the orientation)
The code
// Create leaderboard view w/ default Game Center style
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
// If view controller was successfully created...
if (leaderboardController != nil)
{
// Leaderboard config
leaderboardController.leaderboardDelegate = self; // The leaderboard view controller will send messages to this object
leaderboardController.category = category; // Set category here
leaderboardController.timeScope = GKLeaderboardTimeScopeAllTime; // GKLeaderboardTimeScopeToday, GKLeaderboardTimeScopeWeek, GKLeaderboardTimeScopeAllTime
// Create an additional UIViewController to attach the GKLeaderboardViewController to
myViewController = [[UIViewController alloc] init];
// Add the temporary UIViewController to the main OpenGL view
// [[[CCDirector sharedDirector] openGLView] addSubview:myViewController.view];
[[[[CCDirector sharedDirector] openGLView] window] addSubview:myViewController.view];
// Tell UIViewController to present the leaderboard
[myViewController presentModalViewController:leaderboardController animated:YES];
leaderboardController.view.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90.0f));
leaderboardController.view.bounds = CGRectMake(0, 0, 480, 320);
leaderboardController.view.center = CGPointMake(160,240 );
}
Is there any another method to show it? any help plz
Thank you
huh I found maybe a specific solution so I replace the
if (leaderboardController != nil){...}by the code below.The code :
also need to add a property for the viewController to the
AppDelegate.hFirst add a property declaration, as shown below:Then switch to
AppDelegate.mand synthesize the variable, as shown down:Finally since this code uses UIKit to display a view controller, it’s best to set Cocos2D to use UIViewController rotation.
So go to GameConfig.h, comment out the current
#define GAME_AUTOROTATION kGameAutorotationNone, and set it up as shown: