A node that renders a shape defined by a Core Graphics path.
- iOS 8.0+
- macOS 10.10+
- tvOS 9.0+
- watchOS 3.0+
The graphics path is a collection of straight lines and curves that can define either open or closed subpaths. You can specify separate rendering behavior for the filled and stroked portion of the path. Each part can be rendered using either a solid color or a texture; if you need to render more sophisticated effects, you can also use a custom shader.
Shape nodes are useful for content that cannot be easily decomposed into simple textured sprites. Shape nodes are also very useful for building and displaying debugging information on top of your game content. However, the
SKSpriteNode class offers higher performance than this class, so use shape nodes sparingly.
SKShapeNode shows an example of how to create a shape node. The example creates a circle with a blue interior and a white outline. The path is created and attached to the shape node’s
You can see from the code that the shape has three essential elements:
The interior of the shape is filled. The
fillColorproperty specifies the color used to fill the interior.
You can disable any of these elements by setting its color to
The shape node provides properties that let you control how the shape is blended into the framebuffer. You use these properties the same way as the properties of the
SKSpriteNode class. See