0
我的应用程序从URL获取一些资源,特别是.pvr.ccz
,并将它们保存在Documents
目录中。如何让Cocos2D可以搜索特定路径中的资源?
NSString *documentsDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
...
[responseObject writeToFile:[documentsDirectoryPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", <file_name>, @"pvr.ccz"]] options:NSAtomicWrite error:nil];
之后创建使用.plist
和.pvr.ccz
一个精灵。已在项目中的属性列表中指定的.png
图像列表。
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"<property_list_name>.plist"];
CCSprite *sprite = [CCSprite spriteWithSpriteFrameName:[NSString stringWithFormat:@"<file_name>.png"]];
这将被警告,-[CCFileUtils fullPathFromRelativePath:resolutionType:] : cocos2d: Warning: File not found: <file_name>.pvr.ccz
有没有什么办法让Cocos2D中可以从保存在特定文件夹中的网址搜索资源?或者有什么方法可以在Cocos2D可以找到它们的地方保存来自URL的资源?
未找到的文件不是直接调用的文件,即'.pvr.ccz',当'CCSprite * sprite = [CCSprite spriteWithSpriteFrameName:[NSString stringWithFormat:@“ .png”]];'被调用时,Cocos2D将通过'.plist'中指定的坐标从'.pvr.ccz'中获得该图像。 –
Protocole
我刚刚发现我的解决方案,它将'.plist'和'.pvr.ccz'保存在同一个地方。你的解决方案也是工作而且非常相似。非常感谢你。 – Protocole