Class

SKTextureAtlas

A collection of textures optimized for storage and drawing performance.

Declaration

@interface SKTextureAtlas : NSObject

Overview

An SKTextureAtlas is a collection of textures that were either created from an .atlas folder in the app bundle, or created at runtime. Texture atlases improve memory usage and rendering performance by reducing draw calls. Whenever you have textures that are always used together, store them in an atlas for best results.

SpriteKit implicitly loads an atlas when one of the atlas's textures is accessed. Use textureNamed: when you want to explicitly access a texture atlas’s contents.

The preferred place to create a texture atlas is within an asset catalog (see Creating a Sprite Atlas), but you can also put your source textures in an .atlas folder in the app bundle.

Topics

First Steps

About Texture Atlases

Learn about the benefits of having a texture atlas, and the process for using it.

Accessing Textures

Retrieve textures from an atlas by the textures' filenames.

- textureNamed:

Creates a texture from data stored in the texture atlas.

Creating a Texture Atlas Programmatically

Create an atlas in code.

+ atlasNamed:

Creates a texture atlas from data stored in the app bundle.

+ atlasWithDictionary:

Creates a texture atlas from a set of image files.

Preloading Textures

Gain fine-tuned control over when an atlas is decoded.

- preloadWithCompletionHandler:

Loads an atlas object’s textures into memory, calling a completion handler after the task completes.

+ preloadTextureAtlases:withCompletionHandler:

Loads the textures of multiple atlas objects into memory, calling a completion handler after the task completes.

+ preloadTextureAtlasesNamed:withCompletionHandler:

Loads the textures of multiple atlases into memory, calling a completion handler after the task completes.

Reading Source Image Filenames

Determine whether an atlas contains a particular source image.

textureNames

The names of the texture images stored in the atlas.

Relationships

Inherits From

Conforms To

See Also

Textures

Maximizing Texture Performance

Speed up image display and enable more images to be displayed at one time.

SKTexture

An image, decoded on the GPU, that can be used to render various SpriteKit objects.

SKMutableTexture

A texture whose contents can be dynamically updated.