José María
José María

Reputation: 3063

SKAction sequence temporary delay (initial delay?)

So in the game I'm building I want to repeat an action, but I want it to have an initial delay. So for example, the action would execute three seconds after the user started the game, but after it executes for the first time, there's no longer a three second delay. What can I do to solve this?

Thanks in advance!

Upvotes: 7

Views: 3473

Answers (1)

NMunro
NMunro

Reputation: 1290

You could use an SKAction to make a delay, then put it at the beginning of your sequence.

Apple gives some sample code on sequences:

SKAction *moveUp = [SKAction moveByX:0 y:100.0 duration:1.0];
SKAction *zoom = [SKAction scaleTo:2.0 duration:0.25];
SKAction *wait = [SKAction waitForDuration: 0.5];
SKAction *fadeAway = [SKAction fadeOutWithDuration:0.25];
SKAction *removeNode = [SKAction removeFromParent];

SKAction *sequence = [SKAction sequence:@[moveUp, zoom, wait, fadeAway, removeNode]];
[node runAction: sequence];

You can use SKAction waitForDuration to make a delay.

Upvotes: 7

Related Questions