Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. override func didMoveToView(view: SKView) {
  2.  
  3.  
  4. /// GRID ///
  5.  
  6. grid.anchorPoint = CGPointMake(0.5, 0.5)
  7. grid.position = CGPointMake(self.size.width / 2, self.size.height / 2)
  8. grid.size.width = self.size.width * 0.8
  9. grid.size.height = grid.size.width
  10. grid.zPosition = 10
  11. self.addChild(grid)
  12.  
  13.  
  14. /// BALL ///
  15.  
  16. ball.anchorPoint = CGPointMake(0.5, 0.5)
  17. ball.size.width = grid.size.width / 5
  18. ball.size.height = ball.size.width
  19. ball.position = CGPointMake(0, 0) // THE BALL IS AT THE CENTER OF THE GRID
  20. grid.addChild(ball)
  21.  
  22.  
  23. // SWIPE DOWN DETECTION
  24.  
  25. let swipeDown:UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: Selector("swipeDown:"))
  26. swipeDown.direction = .Down
  27. view.addGestureRecognizer(swipeDown)
  28.  
  29.  
  30. }
  31.  
  32.  
  33. func swipeDown(send:UISwipeGestureRecognizerDirection) {
  34.  
  35.  
  36. let moveAction = SKAction.moveBy(CGVectorMake(0, -grid.size.height / 5), duration: 0.1)
  37. ball.runAction(moveAction)
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement