0
votes

I have N different sprite nodes that I want to fade out one by one in a (slow) sequence. To fade a node I'm doing [node runAction:[SKAction fadeAlphaTo:0.5 duration:1.0]]. This works perfectly, however, how to best apply this action to N different nodes in a sequence?

I know there is a [SKAction sequence:] method that may be useful, but I'm unsure how to implement this with actions on different nodes.

Any help is greatly appreciated! :)

1

1 Answers

1
votes

You're right that SKAction sequence: will do the trick:

// assume you have the count of sprites to fade as spritesToFadeCount

SKAction *fadeSprites = [SKAction sequence: @[
    [SKAction performSelector:@selector(fadeSprite) onTarget:self],
    [SKAction waitForDuration:1.0 withRange:0.0]]];
[self runAction: [SKAction repeatAction:fadeSprites count:spritesToFadeCount]];

Then your fadeSprite method should do the fade, and remove it from it's parent (and if you're keeping a mutable array of sprites to fade, remove it from there).