A texture whose contents can be dynamically updated.


@interface SKMutableTexture : SKTexture


Normally, SpriteKit textures (SKTexture objects) are static, meaning that once created, their contents cannot be changed. This is important because a static image can be more efficiently managed inside the graphics hardware. However, sometimes you need to be able to update the contents of a texture dynamically. In this case, you should use a mutable texture. Because there is a performance penalty for updating the texture’s contents, consider other options first. For example, you can render a texture in hardware using the textureFromNode: method and a node tree.

To use this class, create a mutable texture using either one of its creation methods or those of its superclass. Then, when you need to update the mutable texture object’s contents, call the modifyPixelDataWithBlock: method. Your block is called with the location of the texture in memory. Your block should update this texture and then return.


Creating an Empty Mutable Texture

+ mutableTextureWithSize:

Creates an empty texture with a specific size.

- initWithSize:pixelFormat:

Initializes an empty texture with a specific size and format.

- initWithSize:

Initializes an empty texture with a specific size.

Modifying a Mutable Texture’s Contents

- modifyPixelDataWithBlock:

Modifies the contents of a mutable texture.


Inherits From

See Also


Maximizing Texture Performance

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


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


A collection of textures optimized for storage and drawing performance.