HeeysamH HeeysamH - 2 months ago 12x
Swift Question

Swift Find Scene By Name

How do i make a Swift sprite kit game jump to another scene by searching for the scene with a string. so:

let scenename : String = "Map1"

let scene : SKSCene = SkScene.getscene(scenename)

Do we have something like that?

if not please help me with alternatives!

Thanks for your help and time!


Make a delegate call to your SKView from current scene, which is presenting the scene then present another scene like this:

let newScene = SKScene.init(fileNamed: "MyScene")
newScene!.scaleMode = SKSceneScaleMode.Fil
let reaveal = SKTransition.crossFadeWithDuration(0.01)
let aSKView = self.view as! SKView
aSKView.presentScene(newScene!, transition: reaveal)

Do check for memory leaks ;)