我在游戏中使用 cocos2d 和 View Controller 。我想使用以下代码使用 cocos2d 场景调用 View Controller
PlayAgainViewController* playAgain = [[PlayAgainViewController alloc] initWithNibName:@"PlayAgainViewController" bundle:nil];
[[[CCDirector sharedDirector] openGLView] addSubview:playAgain.view];
它在游戏场景中添加 View Controller View ,但没有使用在 openGl View 上添加的 View 来调用另一个 View Controller 。
最佳答案
//如果UR_COCOS2D_VERSION_2_0
AppController *app = (AppController*)[[UIApplication sharedApplication] delegate];
[app.navController presentModalViewController:playAgain animated:YES];
//Cocos2D 1.0,在appDelegate中使用viewController属性。
AppDelegate* app = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[app.viewController presentModalViewController:playAgain animated:YES];
关于objective-c - cocos2d 与 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12715127/