我怎样才能停止SKAction

时间:2014-04-21 12:02:05

标签: sprite-kit skaction

    _pipeTexture1 = [SKTexture textureWithImageNamed:@"p2"];                                     
    _pipeTexture1.filteringMode = SKTextureFilteringNearest;
    _pipeTexture2 = [SKTexture textureWithImageNamed:@"p1"];                                     
    _pipeTexture2.filteringMode = SKTextureFilteringNearest;

    CGFloat distanceToMove = self.frame.size.width + 2 * _pipeTexture1.size.width;                  
    SKAction* movePipes = [SKAction moveByX:-distanceToMove y:0 duration:0.01 * distanceToMove];    
    SKAction* removePipes = [SKAction removeFromParent];                                            
    _movePipesAndRemove = [SKAction sequence:@[movePipes, removePipes]];                            

    SKAction* spawn = [SKAction performSelector:@selector(spawnPipes) onTarget:self];               
    SKAction* delay = [SKAction waitForDuration:2.0];                                               
    SKAction* spawnThenDelay = [SKAction sequence:@[spawn, delay]];                                 
    SKAction* spawnThenDelayForever = [SKAction repeatActionForever:spawnThenDelay];                
    [self runAction:spawnThenDelayForever];  

如何停止动画动作对某些场景?

1 个答案:

答案 0 :(得分:0)

根据SKNode documentation,您可以使用-(void)runAction:(SKAction *)action withKey:(NSString *)key在首次运行时为操作指定名称。然后,您可以稍后使用- (void)removeActionForKey:(NSString *)key将其删除。