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