SKAction sequence temporary delay (initial delay?)

2019-06-23 09:39发布

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!

1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-06-23 10:43

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.

查看更多
登录 后发表回答