HeeysamH HeeysamH - 1 year ago 138
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!

Answer Source

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 ;)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download