Overlaying a UIView onto a Cocos layer?

1 Answers

CCDirecter replace scene with UIView / nib

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.


I'm new to iOS and Cocos development.

I currently have a basic app going on in my HelloWorldLayer class. It contains my sprites and touch interaction methods and all is well.

I'm trying to add another "panel" (UIView?) over top of what is currently seen. Eventually this panel will have buttons or other things that will interact with the main canvas.

How can I include another UIView onto the canvas screen? Through my appDelegate, or my HelloWorldLayer?


It's a bit tricky but ultimately straightforward once you write a few reusable classes for yourself. To get started, try something like my answer here to this:

Overlaying a UIView onto a Cocos layer?