问题
Is there any way to stop specific action by tag in Sprite-Kit ?
[self stopActionByTag:kTagActionHeroFlapAnim]; //cocos2d
[self stopActionByTag:kTagActionHeroHitAnim];
Like above Cocos2d calls, is there any way in Sprite-Kit ?
SKAction *rep = [SKAction repeatActionForever:animAction]; //how to tag ?
回答1:
You can use Action key to stop specific Action. You need to specify key.
[sprite runAction:rep withKey:@"Move_fade_seq"];
[sprite removeActionForKey:@"Scale_fade_seq"];
回答2:
Your ability to stop an action depends on how you start it.
runAction:
is fire-and-forget. You can't do anything to that specific action running on that specific node after that. (Though you can stop all actions the node is running by calling removeAllActions
.)
If you want to refer to a specific action after you've started running it on a node, start it with runAction:forKey:
instead. The string key you pass has a similar purpose to the integer tag from Cocos2d — it lets you identify the action while it runs so you can do things with it later.
To stop an action that you started with runAction:forKey:
, call removeActionForKey:
.
The SKNode Class Reference describes all the methods for starting, stopping, and managing actions running on nodes.
回答3:
By tag - nope.
By name - nope.
Just by using refs to actions.
来源:https://stackoverflow.com/questions/22411554/spritekit-stop-specific-action-by-tag