Cocos2d-x in Win32, Android and iOS File Read and Write Problems

Source: Internet
Author: User

Recently learning and using the Cocos2d-x framework, although speaking of cross-platform, but in the Development of Vs, and then transplanted to Android or IOS, may also have a variety of problems, minor adjustments are required.

For example, when I perform file read/write operations, it is likely that there is no problem on Win32, but get data failed on IOS.

After several attempts, we found that the following methods can be used to read data directly in Win32, Android, and IOs:

 
# If (cc_target_platform = cc_platform_ios) STD: String fullpath = ccfileutils: sharedfileutils ()-> convert (filename, Foldername); # else STD: String fullpath = ccfileutils :: sharedfileutils ()-> fullpathforfilename (filename); # endif

First, if it is an iOS platform, use the fullpathfromrelativefile method. In this case, filename and the path of its folder are required.

For Win32 or android platforms, use fullpathforfilename to obtain the file.


Unfortunately, it is used on iOSFullpathfromrelativefile. You only need the file name, followed by the folder name. But on Win32 and Android, filename is the name with the folder path.

Therefore, you need to change the filename based on the platform.


However, it is not a big problem to extract the file operations and make adjustments based on the platform judgment.


Reprinted please indicate the source: http://blog.csdn.net/ml3947



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.