Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine several SKScenes in Sprite Kit

I am currently struggling with the following problem:

I am creating a Sprite Kit game in Objective-C, in which I have to use a parallax-animation in all 3 scenes. I use clouds with randomly generated X and Y positions. They appear in the greeting scene, in the game scene and in the highscore scene.

Problem: whenever I switch from one scene to another, I have to restart the parallax-animation, which leads to an messy interruption.

What might be the best strategy to keep the "cloud scene" running all the time in the background, no matter how many times you switch between the game scenes?

Thanks in advance.

like image 312
Objective D Avatar asked Nov 04 '15 15:11

Objective D


1 Answers

For this purpose, consider using only one scene and for each game theme (i.e greeting, game, highscore) use an SKNode which will contain the required elements for its purpose (e.g. the greeting node will have its greeting elements).

This way you can easily keep a "constant" SKNode (i.e. add it once to the scene when the game is first loaded) which will contain your parallax clouds and add/remove required node for the greeting game and highscore when necessary

like image 113
giorashc Avatar answered Sep 30 '22 07:09

giorashc