I have an animation of SCNNodes
triggered by a button. On a subsequent press of the button, the animation reverses. The forward animation always works fine But the reverse animation will sometimes hang up. That is, it will play the portion before the completion handler then freeze. But when I apply any of my three gestures (pan, translate, zoom) it un-hangs and completes the handler portion. The relevant code:
else if buttonToggle_1 == true { buttonToggle_1 = false
let moveWaterBack = SCNAction.moveTo(homePosition_2, duration: 1)
let moveValineBack = SCNAction.moveTo(awayPosition_1, duration: 1)
atomsNode_3.hidden = false
bondsNode_3.hidden = false
hideTransients(true)
atomsNode_3.runAction(moveWaterBack)
bondsNode_3.runAction(moveWaterBack,
completionHandler: {
self.atomsNode_2.runAction(moveValineBack) ;
self.bondsNode_2.runAction(moveValineBack) ;
self.atomsNode_3.removeFromParentNode() ;
self.bondsNode_3.removeFromParentNode() ;
hideTransients(false)
})
}
The hideTransients())
call unhides five nodes, accessing them by name. Sometimes completion hangs, sometimes it doesn't. However if it is hanging in a particular session of remaining on the same page, it will continue to hang on subsequent button toggling. I haven't figured out any cause-effect relationship. I have changed the removeFromParentNode()
calls to hidden = true
and this currently is working but makes me nervous to rely on.
What on Earth could be happening here?
edit 1: Although it's been working pretty consistently, I have seen the hang-ups a couple times (out of many) using the latter code mentioned so this is not strictly due to the removeFromParentNode()
calls.