swift - Error when switching scenes through a button node -
i'm trying switch scenes when press button, however, when click it, nothing happens, , nothing gets printed. there no errors, wondering why not working. node programmed show @ correct size , location, when tap on nothing goes through. thank help.
code:
class levelscene: skscene, skphysicscontactdelegate { var isfingeronblock = false let levelonename = "levelone" override func didmove(to view: skview) { super.didmove(to: view) let pineapple = skspritenode(imagenamed: "ball") pineapple.isuserinteractionenabled = true pineapple.position = cgpoint(x: self.frame.midx - 200, y: self.frame.midy); pineapple.name = "pineapple" addchild(pineapple) } func touchesbegan(touches: nsset, withevent event: uievent) { let touch = touches.anyobject() as! uitouch let location = touch.location(in: self) let nodes = self.nodes(at: location) node in nodes { if node.name == "pineapple" { print("ceeds") if let scene = gamescene(filenamed:"gamescene") { // configure view. let skview = self.view! skview.showsfps = true skview.showsnodecount = true /* sprite kit applies additional optimizations improve rendering performance */ skview.ignoressiblingorder = true /* set scale mode scale fit window */ scene.scalemode = .aspectfit skview.presentscene(scene) } break } } } }
you have declared
func touchesbegan(touches: nsset, withevent event: uievent) there no built-in function signature, , you never call function; therefore function never called.
Comments
Post a Comment