How to check if a specific SKAction is working with a key
I have a SKAction that starts with Key: "running". I also have other key actions. In my case, I would find it convenient if I could check if SKAction is working with the "running" key or not.
Something like:
if (mySpriteNode.runsAction("running")) {
// do some magic code
}
So far, I've just discovered that I can see if there are any actions applied to the node at all, like
mySpriteNode.hasActions
Does anyone have any ideas?
+3
source to share
1 answer
I found this method. This might be what you need:
func action(forKey key: String) -> SKAction?
If there is an action that matches the key, the action object is returned. Otherwise nil is returned.
You can use it like this:
if let _ = mySpriteNode.action(forKey: "someKey") {
// action is running
} else {
// action is not running
}
+5
source to share