gpt4 book ai didi

ios - SKAction waitForDuration() 阻塞 SKAction 序列

转载 作者:行者123 更新时间:2023-11-29 12:13:50 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com