I have a new game I've just started building in sprite kit with swift and I'm wondering how I can use a SKEmitterNode seamlessly across multiple scenes. At the moment my game consists of 3 scenes: menu, game and game over. I want to use the SKEmitterNode in the background across all 3 scenes without any stops. Any help would be much appreciated, thanks!
Asked
Active
Viewed 63 times
2
-
You will need to provide more info because what you are asking is way to generic. You can't have 3 scenes on the screen at once, so I am going to have to assume you are transitioning to each scene. What kind of transition are you using? The simplest approach would be to move your `SKEmitter` to the new scene, and in the `SKTransition`, make sure you enable animations on the new scene – Knight0fDragon Mar 18 '16 at 13:04
-
@Knight0fDragon It looks to me that he just wants the same emitter running in the background in all of his scenes without reseting an actual simulation (emitting) ... So basically he wants an emitter which will survive transitions... – Whirlwind Mar 18 '16 at 13:23
-
@Whirlwind, yeah that is what I am figuring, but I hate assuming. I can't edit the comment now, but I mean move the actual SKEmitter node across the various scenes, not spawn a new one – Knight0fDragon Mar 18 '16 at 13:31
-
@Knight0fDragon Yeah, I understood what you said about passing the emitter around. It make sense, but I wonder how changing a parent of an emitter will affect on existing simulation... – Whirlwind Mar 18 '16 at 13:35
-
1@Whirlwind yeah good question, guess jm1175 could give it a try and let us know – Knight0fDragon Mar 18 '16 at 14:10
-
Thanks, I'll give it a try tomorrow and see how I go. – jm1175 Mar 18 '16 at 15:29
1 Answers
2
Thanks to KnightOfDragon and Whirlwind helping in the comments, simply passing the emitter to the next scene works fine and without interrupting the particles.
I set up the SKEmitterNode
in a 'intro' scene and declared it globally.
Then on the current scene just before moving to the next:
emitter.removeFromParent()
and in the new scene:
addChild(emitter)

jm1175
- 165
- 10