Ios SKTextureAtlas TextureName未在XCode 6 GM种子中自动查找纹理后缀@3x

Ios SKTextureAtlas TextureName未在XCode 6 GM种子中自动查找纹理后缀@3x,ios,xcode,sprite-kit,iphone-6-plus,Ios,Xcode,Sprite Kit,Iphone 6 Plus,我让NSLog my textureAtlas加载了所有my@3x.PNG,但它通过调用TextureName返回缺少的纹理: #define TEXT_MAINMENU @"mainmenu" SKTextureAtlas *textureAtlas = [SKTextureAtlas atlasNamed:@"414x736"]; NSLog(@"atlas: %@", textureAtlas); SKTexture *_MAINMENU = [textureAtlas textureNa

我让NSLog my textureAtlas加载了所有my@3x.PNG,但它通过调用TextureName返回缺少的纹理:

#define TEXT_MAINMENU @"mainmenu"
SKTextureAtlas *textureAtlas = [SKTextureAtlas atlasNamed:@"414x736"];
NSLog(@"atlas: %@", textureAtlas);
SKTexture *_MAINMENU = [textureAtlas textureNamed:TEXT_MAINMENU];
NSLog(@"texture from skatlas: %@", _MAINMENU);
输出如下:

图集:“414x736”83纹理:( " 'mainmenu@3x.png"(279 x 279)",, " 'winreplay@3x.png"(873 x 131)",, " 'bonus128@3x.png"(279 x 279)",, " 'maincake128@3x.png"(279 x 279)",, " 'bonus512@3x.png"(279 x 279)",

skatlas的纹理:“MissingResource.png”(128 x 128)

但是,通过textureWithImageNamed(不是通过SKTextureAtlas TextureName)获取纹理,然后返回到@1x.PNG

SKTexture *_MAINMENU2 = [SKTexture textureWithImageNamed:TEXT_MAINMENU];
NSLog(@"texture from sktexture: %@",_MAINMENU2);
输出如下:

来自sktexture的纹理:“主菜单”(90 x 90)


当然,对于运行良好的同一代码,我也有@1x@2x PNG,我想知道为什么我的textureAtlas/texture不能自动找到我的@3x.PNG?我有什么问题吗?如何修复它?

你可能会得到“丢失的资源”消息,因为您没有使用有效的密钥访问纹理图集。手动创建纹理图集时,通常使用
atlasWithDictionary:
如下所示:

NSDictionary *testDictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"mine@1x.png", @"mine64", @"mine@2x.png", @"mine128", @"mine@3x.png", @"mine256", nil];

SKTextureAtlas *testAtlas = [SKTextureAtlas atlasWithDictionary:testDictionary];
mine64是64x64 png,mine128是128x128 png,mine256是256x256 png。显然,您需要字典的唯一键,因此您必须根据iPhone型号手动编码所需的图像大小,何时可以这样放置图像:

SKSpriteNode *myNode = [SKSpriteNode spriteNodeWithTexture:[testAtlas textureNamed:@"mine256"]];
但是,根据最新的苹果公司文件:

讨论 通常,Xcode会在编译时从项目中包含的图像文件创建纹理地图集。这些地图集是在应用程序包中编译和安装的。但是,有时创建纹理地图集所需的资源在编译时不可用。例如,这些资源可能是程序生成的或从网络下载的工作。但是,您仍然希望纹理地图集的好处能够减少硬件中所需的状态更改数量。您可以使用此方法在运行时生成地图集。这是一个潜在的昂贵操作,最好在游戏循环未运行时执行

我的理解是,Xcode将自动生成所有需要的纹理地图集。考虑到这一点,将以下3个图像添加到项目中:mine@1x.png, mine@2x.png, mine@3x.png然后使用:

SKSpriteNode *myNode = [SKSpriteNode spriteNodeWithImageNamed:@"mine.png"];
将根据屏幕分辨率使用正确的图像


另一种选择是,您可以使用类似于创建自己的纹理地图集的应用程序,并将其添加到项目中。

在这种情况下,“textureAtlas”是什么?第一行似乎缺少一些内容,有两个开始括号,但有三个结束括号。@LearnCos2D感谢您的回复,请查看我的更新!是的,我似乎也不适用=/在最终版本中,有一些内容仍然很不完整