Set an action's name property so you can access it later without needing an instance variable.
Normally, you can’t see which actions a node is executing, and if you want to remove actions, you must remove all of them. If you need to see whether a particular action is executing, or if you want to remove a specific action, use named actions. A named action is characterized by a unique string that identifies the action. Using named actions, you can start, remove, find and replace the actions of a node.
Create and Run a Named Action
The following code creates and runs a new action identified with the
The following key-based methods are available:
Find and Replace an In-Flight Action
The code below shows how you use a name to replace an action that's currently running. The code determines where a mouse click occurred and then runs an action that moves a sprite to the click location. The action duration is calculated ahead of time to move the sprite at a fixed speed. Because this code uses
run(_:, any previous move that's still executing is stopped and replaced by the new action with the same name.