Class

SKSpriteNode

A node that draws a rectangular texture, image or color.

Overview

An SKSpriteNode is a node that draws a texture (optionally blended with a color), an image, a colored square. You can also provide a custom shader to create your own rendering effects.

Sprite nodes can be lit with SKLightNode objects and optionally cast and receive shadows. 3D lighting can be simulated by supplying a separate normal texture or automatically generating a normal texture from an image.

Symbols

Initializing a New Sprite

init(color: UIColor, size: CGSize)

Initializes a colored sprite.

init(imageNamed: String)

Initializes a textured sprite using an image file.

init(texture: SKTexture?)

Initializes a textured sprite using an existing texture object.

init(texture: SKTexture?, color: UIColor, size: CGSize)

Initializes a colored and textured sprite using an existing texture object.

init(texture: SKTexture?, size: CGSize)

Initializes a textured sprite using an existing texture object but with a specified size.

init(imageNamed: String, normalMapped: Bool)

Initializes a textured sprite using an image file, optionally adding a normal map to simulate 3D lighting.

init(texture: SKTexture?, normalMap: SKTexture?)

Initializes a textured sprite with a normal map to simulate 3D lighting.

Inspecting Physical Properties

var size: CGSize

The dimensions of the sprite, in points.

var anchorPoint: CGPoint

Defines the point in the sprite that corresponds to the node’s position.

Inspecting the Sprite’s Texture

var texture: SKTexture?

The texture used to draw the sprite.

var centerRect: CGRect

A property that defines how the texture is applied to the sprite.

var colorBlendFactor: CGFloat

A floating-point value that describes how the color is blended with the sprite’s texture.

Inspecting Color Properties

var color: UIColor

The sprite’s color.

Blending the Sprite with the Framebuffer

var blendMode: SKBlendMode

The blend mode used to draw the sprite into the parent’s framebuffer.

Adding Lighting to a Sprite

var lightingBitMask: UInt32

A mask that defines how this sprite is lit by light nodes in the scenes.

var shadowedBitMask: UInt32

A mask that defines which lights add additional shadows to the sprite.

var shadowCastBitMask: UInt32

A mask that defines which lights are occluded by this sprite.

var normalTexture: SKTexture?

A texture that specifies the normal map for the sprite.

Adding a Custom Shader

var shader: SKShader?

A property that determines whether the sprite is rendered using a custom shader.

Instance Properties

var customPlaygroundQuickLook: PlaygroundQuickLook

A custom playground quick look for this instance.