SKCropNode Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/SpriteKit.framework
Availability
Available in iOS 7.0 and later.
Companion guide
Declared in
SKCropNode.h

Overview

An SKCropNode crops the pixels drawn by its children so that only some of the pixels are rendered to the parent’s framebuffer.

To use a crop node, you add child nodes as you would for any other node. Then you set the crop node’s maskNode property to point to another node. When rendered, the crop mask renders its mask node and uses the resulting values to determine which pixels of its children should be rendered to the parent’s framebuffer.

Tasks

Setting the Mask Filter

Properties

maskNode

The node used to determine the crop node’s mask.

@property(retain, nonatomic) SKNode *maskNode
Discussion

The node supplied to the crop node must not be a child of another node; however it may have children of its own.

When the crop node’s contents are rendered, the crop node first draws its mask into a private buffer. Then, it renders its children. When rendering its children, each pixel is verified against the corresponding pixel in the mask. If the pixel in the mask has an alpha value of less than 0.05, the image pixel is masked out. Any pixel not rendered by the mask node is automatically masked out.

The default value of this property is nil, which indicates that the child nodes should not be cropped.

Availability
  • Available in iOS 7.0 and later.
Declared In
SKCropNode.h