Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. // MARK: Navegação pela tela
  2.  
  3. /** Move a câmera pelo cenário a partir de input proveniente do pinchGestureRecognizer.*/
  4. @objc func updatePosition(_ recognizer: UILongPressGestureRecognizer) {
  5.  
  6. if recognizer.state == .began {
  7. //salva a posição inicial do toque como ultima
  8. previousLocation = recognizer.location(in: recognizer.view)
  9. }
  10.  
  11. if recognizer.state == .changed {
  12.  
  13. if previousLocation == nil { return }
  14.  
  15. let location = recognizer.location(in: recognizer.view)
  16. //cálcula o Δx e Δy da câmera
  17. let difference = CGPoint(x: location.x - previousLocation.x, y: location.y - previousLocation.y)
  18. //utiliza a função criada na postagem 2 para limitar a área do usuário
  19. centerOnPosition(scenePosition: CGPoint(x: Int(position.x - difference.x), y: Int(position.y - -difference.y)))
  20. previousLocation = location
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement