Apress / Mastering-ARKit

source code
Other
9 stars 5 forks source link

Chapter 7 Section: Applying force - Missing swipe gesture implementation instructions. #4

Closed erikuecke closed 2 years ago

erikuecke commented 2 years ago

No instruction given for implementing a swipe gesture to call the func applyForceToRocketship(withGestureRecognizer recognizer: UIGestureRecognizer) method.

There is an example later in the chapter and in the final code sample but if you are a newer iOS Dev and looking for clearer guidance. Create this method:

func addSwipeGesturesToSceneView() {
      let swipeUpGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(ViewController.applyForceToRocketship(withGestureRecognizer:)))
      swipeUpGestureRecognizer.direction = .up
      sceneView.addGestureRecognizer(swipeUpGestureRecognizer)
    }

Call this method in override func viewDidLoad() after addTapGestureToSceneView() is called. Build and swipe up! 🚀