我注意到我的动画看起来很糟糕,即使在我的图形程序中预览的帧看起来很棒.我NSLoged出来,发现它正在以随机顺序加载地图集!我假设它至少会遵循捆绑文件顺序.如何在不自行排序数组的情况下使用捆绑订单.我还将@ 2x图像与其余图像放在一起,还是创建一个单独的图集?
SKTextureAtlas *sleighAtlas = [SKTextureAtlas atlasnamed:@"sleigh"];NSArray *texturenames = [sleighAtlas texturenames];NSMutableArray *sleighTextures = [NSMutableArray new];for (Nsstring *name in texturenames) { NSLog(@"texture: %@",name); SKTexture *texture = [sleighAtlas texturenamed:name]; [sleighTextures addobject:texture];}
它打印出来:
2013-12-04 09:56:54.407 Santa Game[41611:70b] texture: santaAndSleigh.3.png
2013-12-04 09:56:54.407 Santa Game[41611:70b] texture: santaAndSleigh.6@2x.png
2013-12-04 09:56:54.408 Santa Game[41611:70b] texture: santaAndSleigh.8.png
2013-12-04 09:56:54.408 Santa Game[41611:70b] texture: santaAndSleigh.5@2x.png
2013-12-04 09:56:54.408 Santa Game[41611:70b] texture: santaAndSleigh.4.png
2013-12-04 09:56:54.408 Santa Game[41611:70b] texture: santaAndSleigh.9.png
2013-12-04 09:56:54.409 Santa Game[41611:70b] texture: santaAndSleigh.4@2x.png
2013-12-04 09:56:54.409 Santa Game[41611:70b] texture: santaAndSleigh.9@2x.png
2013-12-04 09:56:54.409 Santa Game[41611:70b] texture: santaAndSleigh.5.png
2013-12-04 09:56:54.410 Santa Game[41611:70b] texture: santaAndSleigh.1.png
2013-12-04 09:56:54.410 Santa Game[41611:70b] texture: santaAndSleigh.3@2x.png
2013-12-04 09:56:54.410 Santa Game[41611:70b] texture: santaAndSleigh.6.png
2013-12-04 09:56:54.410 Santa Game[41611:70b] texture: santaAndSleigh.8@2x.png
2013-12-04 09:56:54.411 Santa Game[41611:70b] texture: santaAndSleigh.2@2x.png
2013-12-04 09:56:54.411 Santa Game[41611:70b] texture: santaAndSleigh.2.png
2013-12-04 09:56:54.455 Santa Game[41611:70b] texture: santaAndSleigh.7@2x.png
2013-12-04 09:56:54.456 Santa Game[41611:70b] texture: santaAndSleigh.1@2x.png
2013-12-04 09:56:54.456 Santa Game[41611:70b] texture: santaAndSleigh.10.png
2013-12-04 09:56:54.456 Santa Game[41611:70b] texture: santaAndSleigh.10@2x.png
2013-12-04 09:56:54.457 Santa Game[41611:70b] texture: santaAndSleigh.7.png
谢谢!
解决方法 可能texturenames属性包含纹理名称无序.而不是使用快速枚举用于(;;):for (int i=0; i < sleighAtlas.texturenames.count; i++) { Nsstring *texturename = [Nsstring stringWithFormat:@"santaAndSleigh.%d",i]; [sleighTextures addobject:[explosion2Atlas texturenamed:texturename]];}
虽然如果你将@ 2x图像放入sleighAtlas中,这种方法可能不会起作用.
总结以上是内存溢出为你收集整理的ios – SKTextureAtlas如何按顺序加载纹理全部内容,希望文章能够帮你解决ios – SKTextureAtlas如何按顺序加载纹理所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)