Everyone knows how to add a UIView to an iOS app built with cocos2d-iphone. It’s straightforward, just create the view and then call:

There. Now suppose you want to do the same on Mac OS X. HA! HA! Hawww!

Cocoa’s laughing at your feeble attempts. It’s really just Cocoa’s fault though. Having done a fair amount of work with both SDKs, the Cocoa on OS X just feels … old. Backwards. Confuscated. No, not confusing, literally confuscated – it can’t even spell confusing like everyone else does.

But … there is always a way. On OS X it’s just more often than on iOS a matter of finding the right way. It can be done. Here’s proof:

The Right Way™

The trick here is to create an additional “overlay” NSWindow that’ll hold all of your views. Actually, it’s not the overlay window it’s the overlay window’s content view, which is just an empty NSView. But first things first, step by step.

Continue reading »

Tagged with: