Cocos2D-X porting from Cocos2D

Note that these are not complete equivalents from Cocos2D and most of the porting is done from Cocoa to C++ through Classes and Macros provided by the Cocos2D framework.


Instead NSString use string/const char* and do the formatting with CCString where needed.

NSRange, NSMakeRange and Substrings

This code example finds a substring between two given string patterns.


Use CCArray instead of NSMutableArray iterate with CCARRAY_FOREACH.
If you need an array for CGPoint objects you have to use CCPointArray with CCPoint objects instead.
Reason for this is, CCArray works with objects that inherit from CCNode class, which CCPoint doesen’t.(see CGPoint example)


Use CCPoint instead of CGPoint with CCPointArray.



This is a Macro to create setter and getter methods for class members in one line.
Use it in your header file when defining members.

Scene and Layer

Hello World example for scene and layer.
Don’t release “autorelease” objects like CCScene and most of the objects instanciated with create.
Like the description implies they will be automatically released so there is no need to release them again, but if you do your programm will crash.


Recent Posts

Recent Comments