Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // MARK: Navegação pela tela
- /** Move a câmera pelo cenário a partir de input proveniente do pinchGestureRecognizer.*/
- @objc func updatePosition(_ recognizer: UILongPressGestureRecognizer) {
- if recognizer.state == .began {
- //salva a posição inicial do toque como ultima
- previousLocation = recognizer.location(in: recognizer.view)
- }
- if recognizer.state == .changed {
- if previousLocation == nil { return }
- let location = recognizer.location(in: recognizer.view)
- //cálcula o Δx e Δy da câmera
- let difference = CGPoint(x: location.x - previousLocation.x, y: location.y - previousLocation.y)
- //utiliza a função criada na postagem 2 para limitar a área do usuário
- centerOnPosition(scenePosition: CGPoint(x: Int(position.x - difference.x), y: Int(position.y - -difference.y)))
- previousLocation = location
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement