ios – SKTextureAtlas如何按顺序加载纹理

ios – SKTextureAtlas如何按顺序加载纹理,第1张

概述我使用SKTextureAtlas(.atlas文件夹)来存储我正在使用的动画的帧.我已经对frame.1.png,frame.2.png等帧进行了编号 – 总共有10帧. 我注意到我的动画看起来很糟糕,即使在我的图形程序中预览的帧看起来很棒.我NSLoged出来,发现它正在以随机顺序加载地图集!我假设它至少会遵循捆绑文件顺序.如何在不自行排序数组的情况下使用捆绑订单.我还将@ 2x图像与其余图像 我使用SKTextureAtlas(.atlas文件夹)来存储我正在使用的动画的帧.我已经对frame.1.png,frame.2.png等帧进行了编号 – 总共有10帧.

我注意到我的动画看起来很糟糕,即使在我的图形程序中预览的帧看起来很棒.我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: [email protected]
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: [email protected]
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: [email protected]
2013-12-04 09:56:54.409 Santa Game[41611:70b] texture: [email protected]
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: [email protected]
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: [email protected]
2013-12-04 09:56:54.411 Santa Game[41611:70b] texture: [email protected]
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: [email protected]
2013-12-04 09:56:54.456 Santa Game[41611:70b] texture: [email protected]
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: [email protected]
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如何按顺序加载纹理所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1074785.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存