2012-09-21 6 views
3

내 앱이 게임 센터에 연결할 수 있도록 설정했습니다. 나는 this 가이드를 따라 갔고 C++ 클래스 래퍼를 사용하여 다른 클래스에서 호출했습니다. 저는 iPad (iOS 5.1), iPod Touch 4th Gen (iOS 5.1) 및 iPhone 4s 및 3GS를 테스트 중입니다. 그것은 잘 iPad 장치에서 작동하지만 일부 알 수없는 이유로, 그것은 아이폰과 아이팟에 않습니다. 샌드 박스에 제대로 연결되지만 UI가 표시되지 않거나 UI가 화면 밖에서 표시됩니다. 아이폰에 어떻게됩니까Cocos2d-x로 게임 센터 UI 열기

은 다음과 같습니다

I가 로그인하지 그리고 난이 게임 센터에 액세스하는 경우
  1. , 로그인 창이 나타납니다. 로그인하면 아무 일도 일어나지 않습니다. 그러나 콘솔에보기가 추가되었다고합니다.
  2. 로그인 한 상태에서 게임 센터에 액세스해도 아무런 변화가 없습니다. 그러나 콘솔에보기가 추가되었다고합니다.
  3. 인증 받기 전에 Game Center에 액세스하면 Game Center UI가 나타납니다. 그러나 ...
    • 게임 센터는 가로 모드 (내 앱이 가로 방향이므로 아무 문제가 없음)이지만 위쪽 막대 (완료 버튼이있는 막대)는 세로 방향 인 것처럼 배치됩니다.
    • 전체 UI가 화면의 ~ 30 %에 불과합니다. 사전에

      - (void)showLeaderboardForCategory:(NSString *)category 
      { 
          // Only execute if OS supports Game Center & player is logged in 
          if (hasGameCenter) 
          { 
           // 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 = GKLeaderboardTimeScopeToday; // GKLeaderboardTimeScopeToday, GKLeaderboardTimeScopeWeek, GKLeaderboardTimeScopeAllTime 
      
            // Create an additional UIViewController to attach the GKLeaderboardViewController to 
            myViewController = [[UIViewController alloc] initWithNibName:nil bundle:nil ]; 
      
            // Add the temporary UIViewController to the main OpenGL view 
            // NOTE: This is the part that I think is the suspect. I am not sure if iPhones and iPods support EAGLView. 
            [ [ EAGLView sharedEGLView ] addSubview:myViewController.view ]; 
      
            // Tell UIViewController to present the leaderboard 
            [ myViewController presentModalViewController:leaderboardController animated:NO ]; 
            NSLog(@"Leaderboard opened."); 
           } 
          } 
      } 
      

      이 어떤 도움 감사 및 감사 : 나는 게임 센터 UI를 시작하는 방법

이입니다.

EDIT : OpenFeint 사용은 옵션이 아닙니다.

답변

2

것은 this.Do 사용하지 시도 'EAGLView'

- (void) showLeaderboard 
{ 
    if (!gameCenterAvailable) return; 

    GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init]; 
    if (leaderboardController != nil) { 
     leaderboardController.leaderboardDelegate = self; 

     UIWindow *window = [[UIApplication sharedApplication] keyWindow]; 
     currentModalViewController = [[UIViewController alloc] init]; 
     [window addSubview:currentModalViewController.view]; 
     [currentModalViewController presentModalViewController:leaderboardController animated:YES]; 
    } 

} 
+0

내가 (상단의 "완료"버튼을 사용하여) 게임 센터 창을 닫을 때 나는 이전 장면에 대한 제어를 잃게 제외하고는 잘 작동 – alxcyl

+0

으로 그런데, 나는 [myViewController dismissModalViewControllerAnimated : YES];를 사용한다. [myViewController release];'leaderboardViewControllerDidFinish' 메쏘드에서 – alxcyl

+0

회원 코드'myViewController' 대신에'leaderboardViewControllerDidFinish'에서 인자 ('(UIViewController *) viewController')를 사용하여 고정 시켰습니다. – alxcyl