ios - Set a button as an image in SpriteKit -


i have uibutton restart button game within spritekit , i'd make image. have declared button as:

var ratebtn: uibutton!  

here's current code button:

restartbtn = uibutton(frame: cgrect(x: 0, y: 0, width: view!.frame.size.width / 3, height: view!.frame.size.height / 3)) restartbtn.center = cgpointmake(view!.frame.size.width / 2, view!.frame.size.height) restartbtn.settitle("restart", forstate: uicontrolstate.normal) restartbtn.settitlecolor(uicolor.whitecolor(), forstate: uicontrolstate.normal)  restartbtn.addtarget(self, action: selector("restart"), forcontrolevents: uicontrolevents.touchupinside) self.view?.addsubview(restartbtn)  uiview.animatewithduration(1.0, delay: 0, usingspringwithdamping: 1.0, initialspringvelocity: 1.0, options: nil, animations: ({     self.restartbtn.center.y = self.view!.frame.size.height / 1.4 }), completion: nil) 

so have set out spring effect want image instead of font. how do this?

make button skspritenode. detect touch on by:

for touch: anyobject in touches {          let location = touch.locationinnode(self)          if button.containspoint(location) {               //enter restart function here!          }     } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -