【发布时间】:2020-07-03 06:55:41
【问题描述】:
好吧,我的目标是提取SKScene 的内容,然后对其节点运行一些操作:
func loadSceneNodes() {
let loadedScene = SKScene(fileNamed: "newScene.sks")
// Reads the content of the "Content" node in the newScene.sks
let content = loadedScene!.childNode(withName: "Content") as! SKSpritenode
// I move the content to self
// (THANKS Knight0fDragon for suggestion)
content.move(toParent: self)
// Forces the unpause
self.isPause = false
// Try to run a test action on the node
content.run(.rotate(byAngle: 90, duration: 2.0)) {
print("DONE")
}
print(content.hasActions()) // DEBUG -> it prints TRUE
}
发生的情况是我成功阅读了内容并显示在场景中,但即使hasActions() 结果true 也没有显示动作。
通过玩断点和调试控制台,我发现了一些非常有趣的东西。 content.hasActions() 返回 true 因为所有的 SKActions 都进入了堆栈:
它们看起来像冻结了,因为如果我分配更多动作,它们将一个接一个地堆叠而不会运行。 只有一旦我退出断点(或者我是否暂停然后通过 xCode 播放应用程序)才会执行所有操作。就像应用“需要”刷新一样。
【问题讨论】:
标签: swift xcode sprite-kit game-development skaction