因此,这是一笔交易,我一直在开发基于开源tweeJump的游戏,作为较大应用程序的一小部分。iPhone - 卸载在视图控制器内运行的cocos2d游戏
我已经成功地获得了游戏加载(从一个tableView),并能够玩它,但我不太清楚如何停止运行cocos2d并返回到启动游戏的表视图。我试过在cocos2d里面实现一个按钮来停止CCDirector,但是基本上只是冻结了我的应用程序 - 我不太确定如何弹出视图控制器。我对cocos2d不是很熟悉,所以我会很感激任何帮助。谢谢。
下面是一些相关的代码:
的的appDelegate(不运行游戏,但树立CCDirector供以后使用):
- (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;
}
下面是视图控制器相关的实施(这是我从一个tableViewController加载),这是运行游戏,一切都在的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];
}
}