SKAction waitForDuration() blocking SKAction sequence

拜拜、爱过 提交于 2019-12-24 18:32:48

问题


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") }) ]))

The last skaction does not get called.

But when I remove the second waitForDuration, the last skaction gets called.

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

What is happening here?


回答1:


A node's speed property affects the execution speed of actions run on that node. From the docs,

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.

In your first runBlock, you are setting the speed property of self to 0. This causes the second waitForDuration action to run infinitely slow (assuming actualDuration = duration/speed).



来源:https://stackoverflow.com/questions/32485107/skaction-waitforduration-blocking-skaction-sequence

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!