ios - How to move a sprite using swipe gesture? -


how can move sprite left swiping left, move sprite right swiping right , on?

like if swipe left, sprite moves 20 points left..i using spritekit , swift.

thank you! @jonogilmour

i have resolved in way:

let right = skaction.movebyx(64, y: 0, duration: 0.6)     let left = skaction.movebyx(-64, y: 0, duration: 0.6)     let = skaction.movebyx(0, y: 64, duration: 0.6)     let down = skaction.movebyx(0, y: -64, duration: 0.6)        func swipedright(sender:uiswipegesturerecognizer){         player.runaction(right)     }     func swipedleft(sender:uiswipegesturerecognizer){         player.runaction(left)     }     func swipedup(sender:uiswipegesturerecognizer){         player.runaction(up)     }     func swipeddown(sender:uiswipegesturerecognizer){         player.runaction(down)     }   override func didmovetoview(view: skview) {           let swiperight:uiswipegesturerecognizer = uiswipegesturerecognizer(target: self, action: selector("swipedright:"))     swiperight.direction = .right     view.addgesturerecognizer(swiperight)      let swipeleft:uiswipegesturerecognizer = uiswipegesturerecognizer(target: self, action: selector("swipedleft:"))     swipeleft.direction = .left     view.addgesturerecognizer(swipeleft)      let swipeup:uiswipegesturerecognizer = uiswipegesturerecognizer(target: self, action: selector("swipedup:"))     swipeup.direction = .up     view.addgesturerecognizer(swipeup)      let swipedown:uiswipegesturerecognizer = uiswipegesturerecognizer(target: self, action: selector("swipeddown:"))     swipedown.direction = .down     view.addgesturerecognizer(swipedown) ............ 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -