Hey all.
I have an existing UIKit based application, which is basically a few UIViews. One of these UIView's needs to be an animated cocos2d layer.
I've just added the following code to my app delegate in an attempt to get anything to appear - it's basically what lies within the standard new templates app delegate for a new cocos2d project.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
CC_DIRECTOR_INIT();
application.statusBarStyle = UIStatusBarStyleBlackOpaque;
application.idleTimerDisabled = YES;
// Init the window
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Obtain the shared director in order to...
CCDirector *director = [CCDirector sharedDirector];
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
// set FPS at 60
[director setAnimationInterval:1.0/60];
// Display FPS: yes
[director setDisplayFPS:YES];
// Create an EAGLView with a RGB8 color buffer, and a depth buffer of 24-bits
EAGLView *glView = [director openGLView];
// attach the view to the director
//[director setOpenGLView:glView];
// make the OpenGLView a child of the main window
[window addSubview:glView];
//Add the UIViewController's view
[window addSubView:viewController.view];
// make main window visible
[window makeKeyAndVisible];
// Default texture format for PNG/BMP/TIFF/JPEG/GIF images
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
// You can change anytime.
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
// run
[[CCDirector sharedDirector] runWithScene: [HelloWorld scene]];
return YES;
}
Problem is, this crashes immediately with no console error message or log on either the simulator or device. For brevity's sake, I've replaced my scene with one from the default cocos2d new template called HelloWorld. I don't have a clue why it would crash. If I remove the cocos setup from the delegate, my app runs as norm.
I only want my scene to run on one UIView in my app, any other time should just be a bunch of standard UIKit items.(think a navcontroller with multiple views). Thanks in advance