Swift iOS Sprite Kit - 加载sprite的最佳方法是什么?

时间:2015-05-27 17:44:01

标签: ios swift sprite-kit textures

使用我当前的代码,我使用纹理Atlas来加载整个游戏。这通常一次加载大约2-4个小的低分辨率图像。我认为这是加载图像的最佳方式,但我的游戏明显滞后了峰值。

以下是我使用的代码片段:

let wallAtlas = SKTextureAtlas(named: "walls")

var topPoleSprite = SKSpriteNode(texture: wallAtlas.textureNamed("pole-top-\(randomInt2)"))
var textureTopSprite = wallAtlas.textureNamed("pole-top-1")
topPoleSprite.physicsBody = SKPhysicsBody(texture: textureTopSprite, size: topPoleSprite.size)
self.addChild(topPoleSprite)

最好的方法是什么?这种方法是每次都加载到图像中,可以在开始时加载吗?我应该直接从images.xcassets加载图片吗?

谢谢! 托比。

0 个答案:

没有答案