我想在我的spriteNode上运行两个动画,具体取决于它的旋转.如果值为负,则运行其中一个动画,如果它是正的,则运行另一个.我设法做到这一点(但是我有一个问题).如果Animation1正在运行,并且zRotation更改为正,则它们都会运行,因为它们将永远重复.所以我这样做:
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"];
然后当我想要停止:
[self removeActionForKey:@"animation1"];
但是它一直在运行,那么我该怎么停止呢?谢谢!