Are there any known cases where running an SKAction using runAction does not complete?
I launch several 'runAction' on different SKNode. In order to synchronize all these actions, I use a counter that is incremented inside the completion block of each SKAction. When the counter reach the exact number of launched SKAction then the animations is completed.
From time to time one SKAction does not complete then the animation never complete.
// Several actions are launched...
myNode.runAction(myActions,completion:{
checkCompletion()
})
// Check if all actions completed
//
// numberOfLaunchedActions: number of actions launched
// logDebug: some log helper
func checkCompletion() {
// This counter is initialized earlier
numberOfCompletedActions++
logDebug(">> Actions completed: \(numberOfCompletedActions)/\(numberOfLaunchedActions)")
if numberOfCompletedActions == numberOfLaunchedActions {
/// some statements
logDebug("Animation Completed!")
}
}
Actions are dynamically generated and are composed of sequence of following actions:
waitForDurationscaleTomoveByhideunhide
No removeFromParent nor runAction nor runBlock.
The action I focus my attention on is the following:
let waitAction = SKAction.waitForDuration(0.4)
let scaleAction = SKAction.scaleTo(0.1, duration: 2.0)
scaleAction.timingMode = .EaseOut
let myAction = SKAction.sequence([
waitAction,
scaleAction,
])
There is one known case: adding action after
Remove from parentin asequence: SKAction runAction does not execute completion blockAs explained in comment: