【发布时间】:2016-12-21 01:42:50
【问题描述】:
SKAction.run 操作中的代码块由于某种原因永远不会执行。
澄清一下,startAction 内部的两行由于某种原因从未运行,即使其他行确实运行。
在这些行上放置断点证明这些行永远不会执行。
有什么线索吗?
// Set first frame
let firstFrame = frames[0]
let animationNode = SKSpriteNode(texture: firstFrame)
animationNode.position = CGPoint(x: x, y: y)
// Set start action
let startAction = SKAction.run({
gAudio.playSound(file: .TestSound) // Never runs
self.animationLayer.addChild(animationNode) // Never runs
})
// Set rest of animation
let timePerFrame = 0.5
let animationAction = SKAction.animate(with: frames, timePerFrame: timePerFrame, resize: false, restore: true)
let removeAction = SKAction.removeFromParent()
let animationSequence = SKAction.sequence([startAction, animationAction, removeAction])
// Run animation
animationNode.run(animationSequence)
【问题讨论】:
-
run 是立即的,但是该块将进入队列并且不能保证在调用 run 的确切时间触发,因此一旦您触发它,下一个序列将触发,从而删除在运行中的任何事情发生之前从父节点获得节点
-
@Knight0fDragon 非常感谢,为什么不作为答案发布?这似乎解释了问题,不是吗?
-
仅当动画也没有运行时
-
@Knight0fDragon 仅在动画未运行时?您能否发布答案,因为如果您确定这些细节,它可以解释问题吗?
-
animationAction
标签: swift sprite-kit skspritenode skaction