停止SKAction那RepeatsForever - 雪碧套件 [英] Stop SKAction that RepeatsForever - Sprite Kit
问题描述
我要上取决于其旋转我spriteNode运行两个动画。如果该值为负数运行的动画之一,如果它的正转其他。我想办法做到这一点(种),但我有一个问题。如果动画1正在运行,因为它们是永远重复的变化zRotation转正,它们都运行。所以,我没有这样的:
I want to run two animations on my spriteNode depending on its rotation. If the value is negative run one of the animations, if it's positive run the other. And I managed to do that (kind of) but I have a problem. If Animation1 is running, and zRotation changes to positive, they both run because they are repeating forever. So I did this :
NSMutableArray *walkingTextures = [NSMutableArray arrayWithCapacity:14];
for (int i = 1; i < 15; i++) {
NSString *textureName =
[NSString stringWithFormat:@"character%d", i];
SKTexture *texture =
[SKTexture textureWithImageNamed:textureName];
[walkingTextures addObject:texture];
}
SKAction *spriteAnimation = [SKAction animateWithTextures:Textures timePerFrame:0.04];
repeatWalkAnimation = [SKAction repeatActionForever:spriteAnimation];
[sprite runAction:repeatWalkAnimation withKey:@"animation1"];
,然后当我希望它停止:
and then when I want it to stop :
[self removeActionForKey:@"animation1"];
但它一直运行的动作,我怎么能停止动作,然后呢?谢谢!
but it keeps running the action, how can I stop the action, then? Thank you!
推荐答案
假设的方法其SKAction上运行的节点上被调用。
The method is supposed to be called on the node which the SKAction is running on.
修改
[self removeActionForKey:@"animation1"];
到
[sprite removeActionForKey:@"animation1"];
这篇关于停止SKAction那RepeatsForever - 雪碧套件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!