0

How to repeat this action 3 or 2 times instead of repeating it forever

 SKLabelNode *label = [SKLabelNode labelNodeWithFontNamed:@"AmericanTypewriter-Bold"];
 label.text = @"Boom";
 label.fontColor = [SKColor blackColor];
 label.fontSize = 90;
 label.position = CGPointMake(CGRectGetMidX(self.frame),CGRectGetMidY(self.frame)+25);

 SKAction *disappear = [SKAction fadeAlphaTo:0.0 duration:0.2];
 SKAction *appear = [SKAction fadeAlphaTo:1.0 duration:0.2];
 SKAction *pulse = [SKAction sequence:@[disappear,appear]];

 [label runAction:[SKAction repeatActionForever:pulse]];

 [self addChild:label];
FreeAsInBeer
  • 12,937
  • 5
  • 50
  • 82

1 Answers1

3

You need to use SKAction's repeatAction:count: method documented here.

[label runAction:[SKAction repeatAction:pulse count:3]];
FreeAsInBeer
  • 12,937
  • 5
  • 50
  • 82
  • Glad it worked. You may want to accept my answer so that your "unaccepted answers" score doesn't get too low. Some users of SO are quite perceptive to that kind of thing. – FreeAsInBeer Jun 10 '14 at 18:42