Cocos2d-x 2.x versus 3.x, cocos2d-x2.x

Source: Internet
Author: User

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);}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.