Lirf Lirf - 2 months ago 14
Swift Question

Change SKS file on Scene

can we change the Created levels on Scene.sks files on the GameScene(SKScene)?

If you don't understand me, here more detailed:

I created 2 .sks files (for example one.sks and two.sks) and one subclass of SKScene

Now at start it shows me the one.sks but after some actions it has to change to two.sks but the subclass of SKScene don't change.

Or I have to create 2 classes for each .sks file?

Answer

You do not need a swift file for each sks file. You could have many sks files attached to 1 class, that is how you do level design. So when making your scenes you would start with GameScene(fileNamed:"one") Then when you are ready to go to the next scene, you just do

let nextLevel = GameScene(fileNamed:"two")
self.view!.presentScene(nextLevel) //I do not like using self.view, but that is a different debate I am not getting into.  For simplicity, I am providing it here.
Comments