An image, decoded on the GPU, that can be used to render various SpriteKit objects.
SDKs
- iOS 7.0+
- macOS 10.9+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 3.0+
Framework
- Sprite
Kit
Declaration
class SKTexture : NSObject
Overview
An SKTexture
object is an image that can be applied to SKSprite
and SKShape
objects, particles created by an SKEmitter
object, or tiles used in an SKTile
. 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
SKSprite
andNode SKEffect
objects in your gameNode Any strong references to the texture in your own code
An
SKTexture
object that was used to create the texture objectAtlas