5

저는 cocos2d 2.0에서 프로젝트를 만들었으며 스토리 보드를 사용하여 메인 메뉴를 통합하려고합니다.스토리 보드를 cocos2d 2.0 프로젝트에 통합하는 방법은 무엇입니까?

tinytimgames.com에서 Jerrod Putnam의 튜토리얼을 보았습니다. (새로운 사용자는 게시물 당 2 개의 링크 만 허용 되었기 때문에 링크를 제공 할 수는 없지만 google "cocos2d storyboard"는 첫 번째 링크 임) 그것은 나를 위해 작동하지 않았다. 나는 그것을 정확하게 따라 갔다 (나는 생각한다). 내 cocos2d 프로젝트를 열고 그의 github, CCViewController.m 및 .h에서 파일을 가져온 다음 새로운 스토리 보드 파일을 만들고 지침서를 따랐습니다. 그러나 나는 그것을 실행했을 때, 방금 만든 새 메뉴가 아니라 내 cocos2d 게임에서 곧바로 시작되었습니다.

나는이 튜토리얼 시도 : http://zackworkshopios.blogspot.com/2012/06/cocos2d-with-storyboard-example.html 을하지만, 다시 한번 내가하지 않는 나를 위해 작동하지 않았다 (또는/찾을 수 위치를 모르는)을 libcocos2d.a 및 libCocosDenshion.a 파일.

내가 fidgetware에서 시도 또 다른 튜토리얼 : http://fidgetware.com/Tutorials/page15/page15.html 나는이 튜토리얼했지만 내 프로젝트는 RootViewController라는 파일이없는 (하는 .m 또는 .H) 그렇게하도록되어 코드를 넣어 어디 확실하지 않았다 그 파일들에 들어 가라.

Ray Wenderlich의 튜토리얼도 있지만 스토리 보드는 사용하지 않습니다.

아무도 나에게 도움이되지 않는 이유에 대한 해결책을 줄 수 있거나 스토리 보드를 내 cocos2d 2.0 프로젝트에 통합하는 방법을 자세히 단계별로 설명해 줄 수있는 사람이라면 크게 감사하겠습니다. 또한 내가 가지고있는 또 다른 질문은 cocos2d 2.0 프로젝트로 시작하여 스토리 보드를 통합해야 하는가 아니면 단일보기 응용 프로그램 프로젝트 (또는 다른 것)로 시작하고 내 cocos2d 2.0 부분을 통합해야 하는가하는 것입니다. 미리 감사드립니다!

답변

8

좋아, 나는 결국 Jerrod Putnam의 도움으로 많은 것을 배울 수있었습니다. Jerrod에게 감사드립니다!

http://www.tinytimgames.com/2012/02/07/cocos2d-and-storyboards/

을 다운로드하고 github의 링크에서 파일을 가져올 : 먼저 여기에 자신의 튜토리얼로 이동합니다. 그런 다음 CCViewController의 하위 클래스를 만들고 cocos2dViewController라고 부릅니다. cocos2dViewController.h에서 다음을 복사하여 붙여 넣으십시오.

#import "CCViewController.h" 

@interface cocos2dViewController : CCViewController 

@end 

및 cocos2dViewController에 붙여 넣으십시오.내 게임에 대한 모든 내용이 곳 GamePlay.m이기 때문에합니다 (퍼트 냄의 튜토리얼에서) m 사본이 붙여 넣기가

#import "GamePlay.h" 
#import "cocos2dViewController.h" 

@interface cocos2dViewController() 

@end 

@implementation cocos2dViewController 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    CCDirector *director = [CCDirector sharedDirector]; 

    if([director isViewLoaded] == NO) 
    { 
     // Create the OpenGL view that Cocos2D will render to. 
     CCGLView *glView = [CCGLView viewWithFrame:[[[UIApplication sharedApplication] keyWindow] bounds] 
             pixelFormat:kEAGLColorFormatRGB565 
             depthFormat:0 
           preserveBackbuffer:NO 
             sharegroup:nil 
            multiSampling:NO 
            numberOfSamples:0]; 

     // Assign the view to the director. 
     director.view = glView; 

     // Initialize other director settings. 
     [director setAnimationInterval:1.0f/60.0f]; 
     [director enableRetinaDisplay:YES]; 
    } 

    // Set the view controller as the director's delegate, so we can respond to certain events. 
    director.delegate = self; 

    // Add the director as a child view controller of this view controller. 
    [self addChildViewController:director]; 

    // Add the director's OpenGL view as a subview so we can see it. 
    [self.view addSubview:director.view]; 
    [self.view sendSubviewToBack:director.view]; 

    // Finish up our view controller containment responsibilities. 
    [director didMoveToParentViewController:self]; 

    // Run whatever scene we'd like to run here. 
    if(director.runningScene) 
     [director replaceScene:[GamePlay scene]]; 
    else 
     [director pushScene:[GamePlay scene]]; 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

@end 

당신은 내가 GamePlay.h를 가져올 것을 알 수 있습니다, 즉. 그래서 게임에 대한 헤더 파일을 가져 오십시오. 또한 내가 전화 한 것을 볼 수 있습니다

if(director.runningScene) 
    [director replaceScene:[GamePlay scene]]; 
else 
    [director pushScene:[GamePlay scene]]; 

"GamePlay"는 게임이 포함 된 장면의 이름으로 바꾸십시오. 당신이 그렇게하면, 당신의 AppDelegate.m로 이동이와

application didFinishLaunchingWithOptions 

기능을 대체 : 당신은 거의 다

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    return YES; 
} 

을! 이제 귀하의 스토리 보드 파일은 제공된 링크에 Putnam의 자습서를 따르십시오. 그가 "우리가 방금 만든 클래스에 클래스를 할당"한다고 말하면, cocos2dViewController에 그것을 할당하십시오. 그리고 그게 다야! 프로젝트를 실행하면 아무런 질문을하지 않아도됩니다. bagelboy에

3

나를 사랑하게 될 것입니다.

이 튜토리얼 http://www.tinytimgames.com/2012/02/07/cocos2d-and-storyboards/

다음

여기

트릭이 당신의 아이폰 OS에서 하나 애플리케이션을 메인 스토리 보드를 대상으로하는 메인 스토리 보드를 설정 돼 당신 만들어-에서 "프로젝트 이름"/ 여름에 따라/iPhone/iPod 배포 정보. 당신은 내가 당신에게 내 작업의 소스 코드를 제공합니다 바로 와서 해달라고하면

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 


return YES; 
} 

, 그냥 날 보자 : 그것은 다음과 같습니다 있도록 다음 AppDelegate.m에서 코드를 제거

이 당신의 남자 스토리 보드 선택 알아

+0

self.view.frame를 사용? –

+0

@OscarApeland 미안하지만, 나는 결코 당신에게 돌아 오지 않았다. 불행히도 나는 그 프로젝트를 더 이상 가지고 있지 않으며 내가 그 당시에 한 일을 거의 기억할 수 없다. 제 사과를 받아주세요. –

0

덕분에, 나는 단지 하나의 업데이트가 내 예를 들어

// Create the OpenGL view that Cocos2D will render to. 
    CCGLView *glView = [CCGLView viewWithFrame:self.view.frame 
            pixelFormat:kEAGLColorFormatRGB565 
            depthFormat:0 
          preserveBackbuffer:NO 
            sharegroup:nil 
           multiSampling:NO 
           numberOfSamples:0]; 

[[[UIApplication sharedApplication] keyWindow] bounds] 작동하지 않았다, 그리고 난 당신이 작업 프로젝트 다운로드 링크를하시기 바랍니다 게시 할 수

관련 문제