ios - Swift 2 Game Main Menu -
i trying implement main menu spritekit game, whenever try present scene blank gray screen. here code right now, presents game , not menu:
class gameviewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() if let scene = gamescene(filenamed:"gamescene") { let skview = self.view as! skview skview.showsfps = true skview.showsnodecount = true skview.showsdrawcount = true skview.ignoressiblingorder = true scene.scalemode = skscenescalemode.aspectfill skview.presentscene(scene) } }
i'm new this, , wasn't sure tried replacing gamescene menu scene, gave me gray screen. appreciated.
use code load skscene file created in code , not in scene editor
override func viewwilllayoutsubviews() { super.viewwilllayoutsubviews() if let skview = self.view as? skview { if skview.scene == nil { let scene = menuscene(size: skview.bounds.size) skview.showsfps = false skview.showsnodecount = true skview.showsphysics = true skview.ignoressiblingorder = true scene.scalemode = .aspectfill skview.presentscene(scene) } } }
and in menuscene file need init func
init(size: cgsize) { super.init(size: size) name = "menuscene" }
Comments
Post a Comment