Cocos2dx: Data Storage

Source: Internet
Author: User
The data in the game can be modified during the running of the program. For simple data, you can use UserDefault to store dynamic data, SQLite is more inclined to process large data than xml. in the development process, choose the data storage scheme as needed: UserDefault, xml, json, and sqlite.

The data in the game can be modified during the running of the program. For simple data, you can use UserDefault to store dynamic data, SQLite is more inclined to process large data than xml. in the development process, choose the data storage scheme as needed: UserDefault, xml, json, and sqlite.

Game data is divided into dynamic data and static data

Dynamic Data can be modified while the program is running. For simple data, UserDefault can be used to store dynamic data. SQLite tends to process large data more than xml, select the data storage scheme as needed during the development process: UserDefault, xml, json, and sqlite

Static data is not changed during the program running, such as the title, name of the npc, and price of the item. However, such data may change frequently during the development process, A common practice is to store the data in an external file to prevent hard encoding. For simple data, you can use plist to save the data and use plist to edit the data. By calling

Cocos2d: ValueMap _ dictionary = cocos2d: FileUtils: getInstance ()-> getValueMapFromFile ("static data file name ");

Read the file and cache it to _ dictionary. You can easily use the data in the program.

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.