Instance Method

preload(completionHandler:)

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

Declaration

func preload(completionHandler: @escaping () -> Void)

Parameters

completionHandler

A block called after the texture atlas is loaded.

Discussion

SpriteKit creates a background task that loads the texture data from the atlas object. Then, SpriteKit returns control to your game. After the texture atlas is loaded, your completion handler is called.

If you need to preload multiple texture atlas objects immediately, use the preloadTextureAtlases(_:withCompletionHandler:) method instead.

See Also

Preloading Textures

class func preloadTextureAtlases([SKTextureAtlas], withCompletionHandler: () -> Void)

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

class func preloadTextureAtlasesNamed([String], withCompletionHandler: (Error?, [SKTextureAtlas]) -> Void)

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