1
votes

What I would like to do is have the Cocos2d shared director to replace the current scene with a UIView from UIKit (possibly loaded from a nib). The idea being to cleanly transition between Cocos2d and UIKit.

I've seen a few approaches to this problem. Most of them are about mixing UIKit with Cocos2d in the same scene, I'd like to keep them separate. One approach is to add an instance of UIView as a subview of the directors GLView. Like so:

UIView* cocosView = [[CCDirector sharedDirector] openGLView];
[cocosView addSubview:t];

Overlaying a UIView onto a Cocos layer?

This works but I would have to create a blank scene and transition to that first, then add the UIView, then later remove it and transition to whatever other scene. That's modular but a little messy.

A better approach is to wrap a UIView into a node. Something like: http://www.cocos2d-iphone.org/forum/topic/6889

Is there an official cocos2d extension for this? I'd also like to load the UIView from storyboard/nib if possible. Much obliged.

1

1 Answers

2
votes

replace the current scene with a UIView from UIKit

if you are using cocos2d 1.x: http://www.raywenderlich.com/4817/how-to-integrate-cocos2d-and-uikit

if you are using cocos2d 2.x: CCDirector is a subclass of UIViewController, so you can use usual methods. There's a little bug with delta time calculation after stopping/starting animation, but it's easy to fix.