SpriteKit : Stop specific action by tag

…衆ロ難τιáo~ 提交于 2020-01-05 08:43:13

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!