Contents

SKTexture

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

Declaration

class SKTexture

Mentioned in

Overview

An SKTexture object is an image that can be applied to SKSpriteNode and SKShapeNode objects, particles created by an SKEmitterNode object, or tiles used in an SKTileMapNode. A texture object manages the texture data and graphics resources that are needed to render the image. Most texture objects are created from source images stored in your app bundle—your game’s artwork. Once created, a texture object’s contents are immutable. Multiple sprites can share the same texture object, sharing a single resource.

Deallocating a Texture

After a texture is loaded into the graphics hardware memory, it stays in memory until the referencing SKTexture object is deleted. This means that between levels (or in a dynamic game), you may need to make sure a texture object is deleted. Delete a SKTexture object by removing any strong references to it, including:

  • All texture references from SKSpriteNode and SKEffectNode objects in your game

  • Any strong references to the texture in your own code

  • An SKTextureAtlas object that was used to create the texture object

Topics

First Steps

Reading a Texture’s Size and Optional Source Location

Configuring a Texture’s Behavior for Scaling

Getting a Texture’s Underlying Image

Preloading a Texture for Performance

Instance Properties

Initializers

See Also

Textures