Well, I finally managed to figure it out with a lot of help from Jerrod Putnam, so thanks Jerrod! First go to his tutorial:
http://www.tinytimgames.com/2012/02/07/cocos2d-and-storyboards/
and download and import files from the github link. Then subclass CCViewController and call it cocos2dViewController. In cocos2dViewController.h copy and paste this:
#import "CCViewController.h" @interface cocos2dViewController : CCViewController @end
and in cocos2dViewController.m copy and paste this (from Putnam tutorial)
#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) {
You will notice that I imported GamePlay.h because GamePlay.m is where I have all the content for my game. Therefore, import the header file for your game. You will also see me calling
if(director.runningScene) [director replaceScene:[GamePlay scene]]; else [director pushScene:[GamePlay scene]];
Be sure to replace “GamePlay” with the name of the scene that contains your game. After that, go to your AppDelegate.m and replace
application didFinishLaunchingWithOptions
with this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { return YES; }
You are almost there! Now for your storyboard file, follow the Putnam manual in the link provided. Where he says "and assigns his class to the one we just created," assign it cocos2dViewController. And this! Run the project and it should work if you cannot ask any questions that you have.
source share