xcode - How can I load a spritekit file different than GameScene.swift in my GameViewController.swift? -


in gameviewcontroller.swift, find line

if let scene = gamescene(filenamed:"gamescene") { 

and thought if wanted load other gamescene.swift, change "gamescene" "landingpage" , work dandy. however, figured out, "gamescene" here refers gamescene.sks , not swift file.

i'm looking make game number of levels, each written in own swift file. go to/ how move from, say, level1.swift level2.swift?

if in 1 scene example level selection scene, lets levelselectionscene.swift, can go scene via skview's -presentscene:transition: method.

class levelselectionscene: skscene {      override func didmovetoview(view: skview) { /* ... */}      func selectlevel(level: int) {         let fadetransition = sktransition.fadewithduration(0.3)         if let selectedlevel = createlevelscenewithlevel(level) {             self.view?.presentscene(selectedlevel, transition: fadetransition)          }     }       // not idea if progressively adding new levels,     // it's totally depend on how gonna organize levels.     // since level input not arbitrary, output of     // nil, if does, must developer mistake.     func createlevelscenewithlevel(level: int) -> skscene? {         let levelscene: skscene?         switch level {             case 1: levelscene = level1()             case 2: levelscene = level2()             default: levelscene = nil         }         return levelscene     }  } 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -