【发布时间】:2014-05-07 20:28:56
【问题描述】:
考虑到此图集中的所有文件名都不同,有没有办法从特定图集中加载所有文件?。
我尝试了在这篇文章中找到的方法 Getting a list of files in the Resources folder - iOS 它可以完美运行,但仅适用于基本文件夹,不适用于 .atlas 扩展名
NSString * resourcePath = [[NSBundle mainBundle] resourcePath];
NSString * documentsPath = [resourcePath stringByAppendingPathComponent:@"MYATLAS.atlas"];
NSError * error;
NSArray * directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsPath error:&error];
【问题讨论】:
-
您要预加载纹理,还是立即加载并使用它们?
-
我想加载它们并创建 SKTextures 并将它们全部添加到 NSDictionnary 中并使用文件名作为键
-
我会调整我的答案以使用字典
-
顺便说一句。我认为预加载图集对您来说会很好,您将能够从预加载的图集中快速按名称获取每个纹理:)
-
好的谢谢我现在明白了!
标签: ios objective-c sprite-kit atlas