ios平台的入口那边,CCEAGLView这个类的实例化对象是不是没办法被addsubview到其他的viewcontroller下,只能被set。,这样写,
只显示了帧,其他的场景都没出来
报的这个错
能否弄个小 demo 发给我? 我帮你看看
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
cocos2d::Application *app = cocos2d::Application::getInstance();
app->initGLContextAttrs();
cocos2d::GLViewImpl::convertAttrs();
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
depthFormat: cocos2d::GLViewImpl::_depthFormat
preserveBackbuffer: NO
sharegroup: nil
multiSampling: NO
numberOfSamples: 0];
// Use RootViewController manage CCEAGLView
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
viewController.view = eaglView;
eaglView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.5f];
eaglView.opaque = NO;
UIViewController* View = [[UIViewController alloc] init];
[View addChildViewController:viewController];
[View.view addSubview:viewController.view];
viewController.view.layer.zPosition = 100;
// Set RootViewController to window
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[window addSubview: View.view];
}
else
{
// use this method on ios6
[window setRootViewController:View];
}
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
// IMPORTANT: Setting the GLView should be done after creating the RootViewController
cocos2d::GLViewImpl *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView);
cocos2d::Director::getInstance()->setOpenGLView(glview);
app->run();
return YES;
}
我用如上代码,用cpp-empty-test没办法重现出此问题。最好有个重现demo吧。
行,我重现一下。做个小demo
請問你這問題解決了嗎?
我要做類似的功能,但我連將eaglView變透明都無法做到…
我有照你的方式做了,但我還是做不到,也能發個demo給我嗎?
http://forum.cocos.com/t/ios-android-view-cocos2d-glview/43605/5