Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import SpriteKit
  2.  
  3.  
  4. let plankName = "woodPlank"
  5.  
  6. class PlankScene: SKScene {
  7.  
  8. var plankWood : SKSpriteNode?
  9.  
  10.  
  11. override func didMove(to view: SKView) {
  12.  
  13. plankWood = childNode(withName: "woodPlank") as? SKSpriteNode
  14.  
  15.  
  16. let swipeRight : UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(PlankScene.swipedRight))
  17.  
  18. swipeRight.direction = .right
  19.  
  20. view.addGestureRecognizer(swipeRight)
  21.  
  22. }
  23.  
  24.  
  25. func swipedRight(sender: UISwipeGestureRecognizer) {
  26.  
  27. if sender.direction == .right {
  28.  
  29. let moveOffScreenRight = SKAction.moveTo(x: 400, duration: 0.5)
  30.  
  31. let nodeFinishedMoving = SKAction.removeFromParent()
  32.  
  33. plankWood?.run(SKAction.sequence([moveOffScreenRight, nodeFinishedMoving]))
  34.  
  35. plankWood?.position = CGPoint(x: 0, y: -250)
  36. addChild(plankWood!)
  37. }
  38.  
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement