ios - SKAction waitForDuration() 阻塞 SKAction 序列

标签 ios sprite-kit skaction

self.runAction(SKAction.sequence([ SKAction.waitForDuration(1), SKAction.runBlock({ self.speed = 0; print("pause") }), SKAction.waitForDuration(0.1), SKAction.runBlock({ self.speed = realSpeed; print("resume") }) ]))

最后一个 skaction 没有被调用。

但是当我删除第二个 waitForDuration 时,最后一个 skaction 被调用。

self.runAction(SKAction.sequence([ SKAction.waitForDuration(1), SKAction.runBlock({ self.speed = 0; print("pause") }), SKAction.runBlock({ self.speed = realSpeed; print("resume") }) ]))

这里发生了什么?

最佳答案

节点的speed 属性会影响在该节点上运行的操作的执行速度。从文档中,

The default value is 1.0, which means that all actions run at their normal speed. If you set a different speed, time appears to run faster or slower for all actions executed on the node and its descendants. For example, if you set a speed value of 2.0, actions run twice as fast.

在您的第一个 runBlock 中,您将 selfspeed 属性设置为 0。这会导致第二个 waitForDuration Action 无限慢地运行(假设 actualDuration = duration/speed)。

关于ios - SKAction waitForDuration() 阻塞 SKAction 序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32485107/

相关文章:

ios - 如何让 UILabel 更好地调整大小?

ios - SpriteKit SKNode 不与边缘碰撞

ios - UIBezierPath 上的点或位置

swift - 带有动画 Sprite 的 SKSpriteNode 和 SKAction

objective-c - 无法在 iOS9 中暂停 SKEmitterNode

ios - 停止 SKAction

ios - 从 Swift 函数中的异步调用返回数据

ios - 在 Swift 中暂停和播放 SpriteKit 游戏

ios - 每次以 24 小时制显示 NSDate 中的小时数?

ios - 确保节点可见