Search code examples
sprite-kitskscene

Spritekit - Add SKScene content to another SKScene


I am currently working at a endless runner in Spritekit, but I don't want to have the levels completely self generated. My thought was to create many scenes with "level blocks", which then can be attached to the main scene in a row and thus create a endless level string.

The thing is, I am not really sure, if adding scenes into scenes is a good idea and how I would do this in code anyways.

What would be the best way to create these level blocks?


Solution

  • Ok, I figured out a solution. Maybe I was a bit to fast with going online and asking, but hopefully this will help someone else.

    The way I do it is by creating a SKReferenceNode referencing the Scene, which contains the "Level Blocks". The SKReferenceNode can then be used like any other node.