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:
[Cpp]
# If (CC_TARGET_PLATFORM = CC_PLATFORM_IOS)
Std: string fullPath = CCFileUtils: sharedFileUtils ()-> fullPathFromRelativeFile (filename, foldername );
# Else
Std: string fullPath = CCFileUtils: sharedFileUtils ()-> fullPathForFilename (filename );
# Endif
# If (CC_TARGET_PLATFORM = CC_PLATFORM_IOS)
Std: string fullPath = CCFileUtils: sharedFileUtils ()-> fullPathFromRelativeFile (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, you can use fullPathFromRelativeFile on IOS. You only need the file name first, 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.