SKAction 序列临时延迟(初始延迟?) [英] SKAction sequence temporary delay (initial delay?)

查看:28
本文介绍了SKAction 序列临时延迟(初始延迟?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以在我正在构建的游戏中,我想重复一个动作,但我希望它有一个初始延迟.例如,动作会在用户开始游戏后三秒执行,但在第一次执行后,不再有三秒延迟.我能做些什么来解决这个问题?

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?

提前致谢!

推荐答案

你可以使用 SKAction 来延迟,然后把它放在你的 sequence 的开头.

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

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];

您可以使用 SKAction waitForDuration 进行延迟.

You can use SKAction waitForDuration to make a delay.

这篇关于SKAction 序列临时延迟(初始延迟?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆