When I asked on Twitter what kind of chapter you’d like to see in , I got some great responses! The most votes were for more complex physics examples, all other suggestions were all over the place. Saving and loading, optimizations and organizing bigger games, audio programming and Cocos3D. I think they would all deserve a chapter of their own, and in fact I’ll get you started with ObjectAL and Cocos3D in the chapter about Kobold2D.
But after some research I realized that one of the most frequent issues with an apparent lack in good answers are about integrating Cocoa Touch (UIKit) in a Cocos2D application. Or vice versa, adding Cocos2D to a Cocoa Touch application. There are many things to consider, and it’s easy to run into problems. This topic is especially persistant because on the one hand there are a lot of Cocoa Touch programmers who are starting to use Cocos2D, whereas there are also many Cocos2D users who know little of Cocoa Touch - and both want to use the best of both worlds.
Here’s a preliminary list of topics I’d like to get into:
- RootViewController explained
- Cocoa Touch views in a Cocos2D app (eg In-App Mail)
- Starting & stopping Cocos2D in a Cocoa Touch app
- Properly handling autorotation
- Performance considerations
- Adding iAd banners
If you have a suggestion that is not on this list feel free to add it in a comment!
Follow @gaminghorror | Follow @kobold2d |
|
How about covering UIKit integration with iPad in landscape mode. We had a nasty bug when we integrated UIKit with iPad on a game running in landscape mode.
What was that bug about?
How to integrate UITextFields
Just working on that right now.
It will be great to reat about UIKit stuff like sliders and buttons over cocos2d scene. How to fix them so when Camera follows game hero for example, UIKit stuff stays in place. Thanks
[…] just completed this project for the new book chapter about embedding UIKit views/Cocoa Touch in a Cocos2D application. In that case I embedded the […]
Yes please! I would love to see this. I own the book… Do I get free the chapter free? I will go to the apress site to find out! Thanks Steffen!
Does the latest version of the book show an example of how to add in-app mail and a webview with Cocos2D.
I’ve been struggling to get both working, and if your books shows how, I’ll definitely get it.
Thanks. Steve.
Although there’s a chapter about UIKit, I didn’t cover in-app mail or webviews specifically. It’s not that hard though, just add the UIKit view to cocos2d’s openGL view:
[CCDirector sharedDirector].view addSubView:yourUIKitView];
There’s a number of things to be aware of when mixing UIKit and cocos2d. For example you can’t draw cocos nodes both on top and below a UIKit view. Creating a UIKit view in the background requires extra steps (transparent GL view, clear color). Position is different because cocos2d and UIKit use different coordinate systems. Rotation of the UIKit view may be incorrect, though the latest cocos2d 2.1 beta fixes most of the orientation issues.