METS BLOG

METS BLOG

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.

NSString

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.

NSMutableArray

Use CCArray instead of NSMutableArray iterate with CCARRAY_FOREACH.
Important:
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)

CGPoint

Use CCPoint instead of CGPoint with CCPointArray.

NSTimer

CC_SYNTHESIZE

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.
Important:
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.

Usage


Leave a Reply

Your email address will not be published. Required fields are marked *