SKAction.run
アクション内のコードブロックは何らかの理由で実行されることはありません。SKAction実行アクション内のコードは実行されません
明確にするため、startAction
の2行は、他の行が実行されても何らかの理由で決して実行されません。
これらの行にブレークポイントを置くと、それらの行は決して実行されません。
何か手掛かりがありますか?それは現場に配置されるまで
// 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)
実行即時での実行を開始する必要がありますが、ブロックは、キューに行くと呼ばれる正確な時間の実行時に起動するように保証するものではありません実行すると何かが起きる前に、ノードを親から削除します。 – Knight0fDragon
@ Knight0fDragonはとても感謝しています。答えとして投稿してみませんか?これは問題を説明するように思われる、ない? – Crashalot
アニメーションが実行されていない場合のみ – Knight0fDragon