I have an SKSpriteNode which is running an actionForever. This SKSpriteNode is changing the object on a collision the problem is that because the other action is running forever it will change back to that. Is there a way to stop an action?
SKTexture* groundOverlay = [SKTexture textureWithImageNamed:@"layer-5"];
groundOverlay.filteringMode = SKTextureFilteringNearest;
SKAction* moveOverlaySprite = [SKAction moveByX:-groundOverlay.size.width*2 y:0 duration:0.01 * groundOverlay.size.width*2];
SKAction* resetOverlaySprite = [SKAction moveByX:groundOverlay.size.width*2 y:0 duration:0];
moveOverlaySpritesForever = [SKAction repeatActionForever:[SKAction sequence:@[moveOverlaySprite, resetOverlaySprite]]];
for( int i = 0; i < 2 + self.frame.size.width; ++i ) {
// Create the sprite
sprite1 = [SKSpriteNode spriteNodeWithTexture:groundOverlay];
[sprite1 setScale:1.0];
sprite1.position = CGPointMake(i * sprite1.size.width, sprite1.size.height / 2);
[sprite1 runAction:moveOverlaySpritesForever withKey:@"bg2"];
[self addChild:sprite1];
}