简体   繁体   English

SKAction序列暂时延迟(初始延迟?)

[英]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! 提前致谢!

You could use an SKAction to make a delay, then put it at the beginning of your sequence . 您可以使用SKAction进行延迟,然后将其放在sequence的开头。

Apple gives some sample code on sequences: Apple提供了一些序列示例代码:

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. 您可以使用SKAction waitForDuration进行延迟。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM