Use the Objective-C game engine in a game on iPhone C ++?

You often hear that C ++ is preferable to Objective-C for games, especially in a resource-constrained environment such as the iPhone. (I know that you still need a little Objective-C to talk to iPhone services first.) However, the 2D game selection engine these days seems to be Cocos2d, which is Objective-C.

I understand that what Apple calls "Objective-C ++" allows you to mix C ++ and Objective-C classes in one file, but you cannot mix and match language constructs within the same class or function.

So, is it wise / possible to use Cocos2d to play in C ++? Need to write a lot of glue code? I would like to avoid some heavy lifting that requires a direct OpenGL-ES approach.

+5
source share
2 answers

I am currently creating a prototype game with Cocos2. I write the logic of a game in C ++ using Chipmunk and then use Cocos to implement the presentation layer. You really can freely mix C ++ and Objective-C in one class, function and line of code. I'm sure there are limitations, for example, you probably can't mix Objective-C and the syntax of the C ++ method definition in the class interface (I really didn’t think to try), but for most practical purposes you can move around freely.

iPhone, Objective-C. , - , . ​​ ++, , Objective-C .

+3

, Objective-C ++ ++ Objective-C. Objective-C, , C ++, ++. Objective-C , ++, .

+7

All Articles