Olex
Olex

Reputation: 1656

Xcode Views and Cocos2d Layers in one project

I have task to make simple app from three Views:

And maybe one more View for menu to switch between them. How can I mix ViewControllers and Layers in one project? Do i need start project from Xcode or Cocos2d template?

Upvotes: 0

Views: 742

Answers (1)

sergio
sergio

Reputation: 69027

One possible approach is starting with a Cocos2D project and then using CCUIViewWrapper to display any view as a CCNode. This approach is the best one if you can handle all of your views inside of the same Cocos2D scene.

If you are planning of building, e.g., a navigation controller based app, then the opposite strategy could be more adequate: start with a "normal" app and then, when you need it (i.e., in your third view controller), add Cocos2d's GLView to your view controller view:

[myViewController.view.layer addSublayer:[[CCDirector sharedDirector] glView].layer];

or:

[myViewController.view addSubview:[[CCDirector sharedDirector] glView]];

You will need to import QuartzCore/QuartzCore.h to be allowed to use CALayers.

Upvotes: 1

Related Questions