func collisionHappened() {
let explosion = SKEmitterNode(fileNamed: "rocketExplosion")
rocket.addChild(explosion)
let sceneChange = gameOverScene(size: self.size)
sceneChange.scaleMode = scaleMode
let reveal = SKTransition.crossFadeWithDuration(3)
self.view?.presentScene(sceneChange, transition: reveal)
reveal.pausesOutgoingScene = false
}
I have attached my particle effect to the node I want to "explode" when a collision happens, thus ending the game. I then want the scene to change to the game over scene. If the outgoing scene pauses then the particle effect doesn't happen, but now I've set it to not pause, collisions keep happening and the game over scene never appears as the game keeps going back to the outgoing scene. To overcome this I thought I could add:
rocket.removeFromParent()
so that no more collisions can happen, BUT this means that the particle effect doesn't happen. Is there any way to make it so that the particle effect happens, then the rocket is removed so that I can have both?
I hope this makes sense!
If I understand your question correctly, you could add the particle effect as a child of your
SKScene
subclass instead of a child ofrocket
. Therefore, when you remove the rocket, the particle effect won't also be removed. Just make sure you set theSKEmitter
's position to be therocket
's position to have the particles appear in the correct place. For example: