Title says it all. How do i use a sprite sheet in swift and sprite kit? I\'ve searched google, stack exchange, and the apple documentation and I can\'t figure this one out.
In xcode 7, you can use Images.xcassets to create a sprite atlas.
If you drag in all three image sizes with the proper suffix (@2x and @3x) it will automatically populate the images for you.
Then to use these assets in code simply write:
let atlas = SKTextureAtlas(named: "Sprites")
let texture = atlas.textureNamed("ball")
let sprite = SKSpriteNode(texture: texture)
you can be less specific and just specify a texture:
let texture = SKTexture(imageNamed: "ball")
let sprite = SKSpriteNode(texture: texture)
If you're looking to use an already created sprite sheet, check out this answer on SO: Using sprite sheets in xcode.