After some time away, I’ve recently started a new Cocos2d 4.0 project. Despite my whole distaste for the all the resource file copying that goes on for PC ( V4.0 PC Resources folder ), I thought I would bite the bullet and keep an open mind and try to ‘go with the flow’ and use it in its default state for this project.
Here I am a few days later, and I think I might have already found a bug - or if not, I would love to know the ‘proper’ way of doing it without having to alter the Cocos2d engine code.
I simply wanted to get a list of files in a directory, which shouldn’t be all that difficult…but was having zero luck at all. (Using FileUtils::listFilesRecursively()) Listing the files wasn’t working at all, ‘FullPathForFilename()’, inside the CC2d engine function FileUtils::listFilesRecursively(), was always returning “” (none) for my directory. Even when I tried to simply list the contents of the ‘textures’ directory (which is a Cocos2d engine created directory!!), it would return ‘no directory found’. Keep in mind I have ALL my textures in there and have been using them completely successfully, but when I want to list the contents of the directory, it tells me that the directory does not exist.
So what I did was replace the first line of FileUtilsWin32::listFilesRecursively
“std::string fullpath = fullPathForFilename( dirPath );” with
“std::string fullpath = fullPathForDirectory( dirPath );”
Like magic, the directory is now ‘found’ by Cocos! So - I guess this is either a bug report, or if not - what should I be doing differently instead of having to alter the Cocos2d engine code to view the contents of the directory?
-HUGE fan of Cocos2d-X, just not the PC file resource copying part. (Again, in just a matter of days I’ve already had issues with changed resource files not properly getting copied, and other related issues, that NEVER happened with the old method, and didn’t require massive amounts of file copying just to run the app on PC.)