Type Method

followPath:asOffset:orientToPath:speed:

Creates an action that moves the node at a specified speed along a path.

Declaration

+ (SKAction *)followPath:(CGPathRef)path asOffset:(BOOL)offset orientToPath:(BOOL)orient speed:(CGFloat)speed;

Parameters

path

A path to follow.

offset

If YES, the points in the path are relative offsets to the node’s starting position. If NO, the points in the node are absolute coordinate values.

orient

If YES, the node’s zRotation property animates so that the node turns to follow the path. If NO, the zRotation property of the node is unchanged.

speed

The speed at which the node should move, in points per second.

Return Value

A new action object.

Discussion

When the action executes, the node’s position and zRotation properties are animated along the provided path. The duration of the action is determined by the length of the path and the speed of the node.

This action is reversible; the resulting action creates a reversed path and then follows it, with the same speed.

See Also

Animating a Node's Position Along a Custom Path

+ followPath:duration:

Creates an action that moves the node along a relative path, orienting the node to the path.

+ followPath:speed:

Creates an action that moves the node along a relative path at a specified speed, orienting the node to the path.

+ followPath:asOffset:orientToPath:duration:

Creates an action that moves the node along a path.