Cocos2d-x 2.x versus 3.x, cocos2d-x2.x
Common class name changes in Cocos2d-x
In the following table, the class name is converted to delete the CC prefix directly.
Cocos2d-x class name change
The conversion of class names in the following table is relatively large.
CCString usage change
Before:
1 |
CCString* str = CCString::createWithFormat( "%s.png" , "picture" ); |
Now:
1 |
std::string str = StringUtils::format( "%s.png" , "picture" ); |
CCDictinoary usage change
Before:
12 |
CCDictionary* dict = CCDictionary::createWithContentsOfFile( "name.plist" ); CCArray* arr = (CCArray*) data->objectForKey( "Levels" ); |
Now:
123 |
std::string path = FileUtils::getInstance()->fullPathForFilename( "name.plist" ); ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(path); ValueVector arrLevels = data.at( "Levels" ).asValueVector(); |
CCArray usage change
Here is the standard usage of the C ++ vector container.
The following information comes from here.
Touch usage change
Usage change of Singleton class
CCTime usage change
CCTime has been deleted in Cocos2d-x v3.
Example:
1234 |
static inline float getTimeDifferenceMS(timeval& start, timeval& end) { return ((((end.tv_sec - start.tv_sec)*1000.0f + end.tv_usec) - start.tv_usec) / 1000.0f); }
|