Article

Creating a Shape Node from an Array of Points

Create jagged or smooth shapes from the same array of points.

Overview

An SKShapeNode object can be initialized with an array of points describing a path. The shapeNodeWithSplinePoints:count: method can smoothly interpolate between these points to create a curve rather than the series of straight lines created by shapeNodeWithPoints:count:.

Given an array of the following points: [(0, 0), (100, 100), (200, -50), (300, 30), (400, 20)], shapeNodeWithSplinePoints:count: creates the shape rendered below in red and shapeNodeWithPoints:count: creates the shape below rendered in blue in Figure 1.

Figure 1

Shape nodes created from points

Shape nodes created from points

See Also

Creating a Shape from an Array of Points

+ shapeNodeWithPoints:count:

Creates a shape node from a series of points.

+ shapeNodeWithSplinePoints:count:

Creates a shape node from a series of spline points.