Contents

Action Initializers

Use these functions to create actions.

Overview

Most actions implement specific predefined animations that are done for you by SpriteKit. If your animation needs fall outside of the suite provided here, then you should:

  • Consider using the methods in Creating Custom Actions below (never subclass SKAction)

  • Consider the advice in Drive Game Logic

Choose an Initializer for the Property You Want to Alter

Most actions allow you to change a node’s properties and some actions specifically apply to specific nodes, like SKSpriteNode’s actions for animating its color or texture.

Here are the most common animated properties:

  • Changing a node’s position and zRotation

  • Changing a node’s size or scaling properties

  • Changing a node’s visibility or making it translucent

  • Changing a sprite node’s contents so that it animates through a series of textures

  • Colorizing a sprite node

  • Playing sounds

  • Removing a node from the node tree

  • Calling a block

  • Invoking a selector on an object

See Action Initializers for a full list of action types.

Chaining Actions

Actions can be chained together in multiple ways:

  • A sequence action has multiple child actions. Each action in the sequence begins after the previous action ends.

  • A group action has multiple child actions. All actions stored in the group begin executing at the same time.

  • A repeating action stores a single child action. When the child action completes, it is restarted.

To delay a subsequent action in the chain, insert a wait(forDuration:) action in the sequence, and remember that groups, sequences, and repeating actions may be nested.

Topics

Animating a Node’s Position in a Linear Path

Animating a Node’s Position Along a Custom Path

Animating the Rotation of a Node

Controlling the Action’s Speed

Animating the Scaling of a Node

Animating the Transparency of a Node

Animating a Node’s Texture

Animating Properties of a Node’s Physics Body

Reversing an Animation

Animate the Warping of a Node

Controlling the Audio of a Node

Removing a Node from the Scene

Running Actions on Children

Chaining Actions

Delaying Actions

Performing Inverse Kinematics

Creating Custom Actions

Controlling Node Visibility

See Also

First Steps