Calling removeChild() or removeAllChildren() does not immediately redraw the parent without the child?
I call the following in my GameScene within its didBegin
function when two bodies collide:
func markStake(theUStake: SKSpriteNode) {
let particleName = "smokeParticle.sks"
if let emitter = SKEmitterNode(fileNamed: particleName) {
emitter.position = theUStake.position
theUStake.addChild(emitter)
}
} // markStake
Later I call the following in my GameViewController when I start the Game over:
func initAllStakes() {
for theUStake in UStakes {
theUStake.removeAllChildren()
}
} // initAllStakes
markStake
works with the specified collision.
But calling initAllStakes()
[as shown above] does not redraw the parent UStake
. Only if I add code to redraw the UStakes
within initAllStakes()
do the particle
children disappear.
- Note that UStakes is a global in my
AppDelegate
:
var UStakes: [SKSpriteNode] = [myU1, myU2, myU3, myU4, myU5]
- and that elsewhere, for example:
myU2 = SKSpriteNode(imageNamed: U2Img)
Any ideas would be appreciated.