Resource finding is not robust
There are some corner cases in which certain directory structures will not work with CocosBuilder. The problem lies with the relativePathFromAbsolutePath method in ResourceManagerUtil.
Here's an example of a project setup that's broken:


When I set a sprite frame to be a resource in the "Cocosbuilder Raw Assets Android" directory, the relativePathFromAbsolute path returns a bad relative path. The issue lies with "Cocosbuilder Raw Assets Android" having the same prefix as the "Cocosbuilder" directory in which the project file lives.
+ (NSString*) relativePathFromAbsolutePath: (NSString*) path
{
NSArray* activeDirs = [[ResourceManager sharedManager] activeDirectories];
for (RMDirectory* dir in activeDirs)
{
// Old Code
//NSString* base = dir.dirPath;
// New Code
NSString* base = [NSString stringWithFormat:@"%@/", dir.dirPath];
if ([path hasPrefix:base])
{
// Old Code
//NSString* relPath = [path substringFromIndex:[base length]+1];
// New Code
NSString* relPath = [path substringFromIndex:[base length]];
return relPath;
}
}
NSLog(@"WARNING! ResourceManagerUtil: No relative path");
return NULL;
}
Replacing the two lines indicated seems to fix the issue for me, and works in brief testing. I'm new to Git, so sorry about not having a pull request. I'm also not sure this change won't introduce other bugs or side-effects.
This needs further investigation!