I am creating a maze, I need to move the line that is created on panGestureRecognized to adapt to the motion of my finger:
Code:
@IBAction func panGestureRecognized(_ sender: UIPanGestureRecognizer) {
// print("started")
if let scene = self.scene, let view = sender.view {
let location = sender.location(in: view)
let translation = sender.translation(in: view)
let velocity = sender.velocity(in: view)
do {
audioPlayer = try AVAudioPlayer(contentsOf: beginSound)
audioPlayer.play()
} catch {
// couldn't load file :(
}
self.view.layer.addSublayer(lineShape)
}
else if sender.state == .changed {
// scene.panChanged(location: cameraLocation, translation: cameraTranslation, velocity: cameraVelocity)
let linePath = UIBezierPath()
linePath.move(to: CGPoint(x: 368.0, y: 299.5))
linePath.addLine(to: location)
lineShape.path = linePath.cgPath
}
else if sender.state == .ended {
// scene.panEnded(location: cameraLocation, translation: cameraTranslation, velocity: cameraVelocity)
// sender.setTranslation(CGPoint(x: 0, y:0), in: view)
lineShape.path = nil
lineShape.removeFromSuperlayer()
do {
audioPlayer = try AVAudioPlayer(contentsOf: failedSound)
audioPlayer.play()
} catch {
// couldn't load file :(
}
print("ended")
}
}
}
How can I rotate the line to the left?
