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