user3725724
user3725724

Reputation: 15

How to repeat this action 3 times instead of repeating it forever- Sprite Kit

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];

Upvotes: 0

Views: 491

Answers (1)

FreeAsInBeer
FreeAsInBeer

Reputation: 12979

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

[label runAction:[SKAction repeatAction:pulse count:3]];

Upvotes: 3

Related Questions