申し訳ありませんが、私は最終的にジェロッドパトナムから多くの助けを借りてそれを理解することができました。まず、ここで彼のチュートリアルに行く:
http://www.tinytimgames.com/2012/02/07/cocos2d-and-storyboards/
とgithubのリンクからファイルをダウンロードしてインポートします。次に、CCViewControllerのサブクラスを作成し、cocos2dViewControllerという名前を付けます。 cocos2dViewController.hで次のようにコピーして貼り付けます。
#import "CCViewController.h"
@interface cocos2dViewController : CCViewController
@end
とcocos2dViewControllerに貼り付けます。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.mがあるので、つまり、私はGamePlay.hを輸入していることに気づくでしょう。だからあなたのゲームのヘッダーファイルをインポートします。また、私が電話することがわかります
if(director.runningScene)
[director replaceScene:[GamePlay scene]];
else
[director pushScene:[GamePlay scene]];
"GamePlay"をあなたのゲームが入っているシーンの名前に置き換えてください。あなたはほとんどそこにいる
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}
:あなたがそれを行うたら、AppDelegate.mに移動し、これであなたの
application didFinishLaunchingWithOptions
機能を交換してください!あなたのストーリーボードファイルは、提供されたリンクのパトナムのチュートリアルに従ってください。彼が "私たちが作成したばかりのクラスにそのクラスを割り当てる"と言うと、それをcocos2dViewControllerに割り当てます。以上です!プロジェクトを実行すると、あなたは持っている質問を自由に感じることができます。 bagelboyへ
を使用し、あなたが作業し、プロジェクトのダウンロードリンクをしてください投稿することができますか? –
@OscarApelandすみません、私はあなたに戻ったことはありません。残念ながら、私はもうそのプロジェクトを持っておらず、私が当時のことを思い出したことはほとんどありません。どうか許してください。 –