2012-09-20 3 views
0

cocos2d CCDirector 뷰와 내 자신의 UIView를 모두 포함 할 컨테이너 뷰가있는 Kobold2D 앱을 만들고 싶습니다. 설명서에서 AppDelegate의 alternateView 메서드를 사용하여이 작업을 수행 할 수 있지만이 메서드를 사용하는 방법과 정확히 반환해야하는 것을 볼 수는 없습니다. 예를 들어 주시겠습니까?Kobold2D의 AppDelegate alternateView를 사용하여 rootViewController를 대체하는 방법

답변

1

단순히 UIView를 반환해야합니다.

@implementation AppDelegate 

-(id) alternateView 
{ 
    // we want to be a dummy view the self.view to which we add the glView plus all other UIKit views 
    KKAppDelegate* appDelegate = (KKAppDelegate*)[UIApplication sharedApplication].delegate; 

    // add a dummy UIView to the view controller, which in turn will have the glView and later other UIKit views added to it 
    CGRect bounds = [appDelegate.window bounds]; 
    UIView* dummyView = [[UIView alloc] initWithFrame:bounds]; 
    [dummyView addSubview:[CCDirector sharedDirector].view]; 

    return dummyView; 
} 

@end 

이 코드는 프로젝트의 AppDelegate.m

+0

감사 스테 간다 : 템플릿 프로젝트은 "UIKit보기와적인 Cocos2D는"정확히 컨테이너보기의이 종류를 만들 수 alternateView 방법을 사용합니다. Kobold2D 초보자로서, 때로는 '명백한'것이 분명하지 않습니다. 이제는 실제로 도움이되는 구조를 볼 수 있습니다. –

+1

안녕하세요. 나는이 코드를 alternateView에 넣으려고 시도해 봤지만 중단 점을 넣어 봤지만 함수가 호출되지 않는 것처럼 보입니다. alternateView가 호출되도록 설정이 필요한 switch/config가 있습니까? –

+0

안녕하세요, 폴 솔루션을 찾았습니까? – user810395