PDA

View Full Version : Objective-C and C++? (And Qt!)



raydot
March 28th, 2008, 04:44 PM
All,

For a personal project I want to create a simple 2D game that I can use to build out some AI classes and the like in C++.

Does anyone know of any resources that describe how to add C++ classes into your XCode projects? Everything out there seems to be written in Objective-C, or doesn't include any discussion of graphics (not game-type graphics, at least).

I don't mind doing the graphics whichever way but I'd like the AI classes to be in C++. Any suggestions on how to bridge the gap? Can Objective-C and C++ even be mixed in a single application? Any thoughts on Qt?

Thanks.

Mikuro
March 29th, 2008, 03:28 AM
Objective-C and C++ can indeed be mixed, in a hybrid called Objective-C++. The short answer is that you need to rename your Objective-C .m files to .mm to use C++ code in them. See http://www.cocoadev.com/index.pl?ObjectiveCPlusPlus for more info. (And bookmark that site, because it will be your new best friend.)

As for graphics, you'd probably want to use OpenGL, or perhaps find a C/C++ sprite framework based on OpenGL.

raydot
March 29th, 2008, 01:46 PM
Thanks Mikuro! This is a huge help. I knew a solution had to be out there.