Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 512
José María Avatar asked Aug 27 '14 18:08

José María


1 Answers

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.

like image 78
NMunro Avatar answered Nov 03 '22 20:11

NMunro