So here's the deal, I've been making a game based off of the open-source tweeJump as a small part of a larger application.
I have successfully gotten the game to load (from a tableView) and am able to play it, but I am not quite sure how to stop running cocos2d and return to the table view that starts the game. I have tried implementing a button inside cocos2d that stops the CCDirector, but that basically just freezes my application - I am not quite sure how to pop out the view Controller. I am not really that familiar with cocos2d, so I would appreciate any help. Thanks.
Here's some relevant code:
The appDelegate (this does not run the game, but sets up the CCDirector for later use):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Add the tab bar controller's current view as a subview of the window
[window addSubview:tabBarController.view];
[application setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];
[[CCDirector sharedDirector] setPixelFormat:kRGBA8];
[[CCDirector sharedDirector] setAnimationInterval:1.0/kFPS];
[CCTexture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];
[window makeKeyAndVisible];
return YES;
}
Here is the relevant implementation for the view controller (which I load from a tableViewController) that's running the game, everything is in loadView:
(void)loadView{
if (!load) {
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
load = YES;
[[CCDirector sharedDirector] attachInWindow:window];
[window makeKeyAndVisible];
CCScene *scene = [[CCScene node] addChild:[Game node] z:0];
[[CCDirector sharedDirector] runWithScene: scene];
}
}