As the title says, how can I accomplish this? I can get the first touch but I don't know how to get the last touch if it is a swiping gesture. With the following code I get the error: value of type 'Set' has no member 'last'. Not really sure how to get the position when the touch is released.
override func touchesMoved(_ touches: Set<UITouch>, with: UIEvent?){
let firstTouch:UITouch = touches.first! as UITouch
let lastTouch:UITouch = touches.last! as UITouch
let firstTouchLocation = firstTouch.location(in: self)
let lastTouchLocation = lastTouch.location(in: self)
}
I want to get the location of the first point and the location of the second point. Then I would like to use the duration of the swipe, the size of the line, and the angle of the line to create an impulse vector to use on an SKNode. Is there any way to extract this information using the UITouch? Any help is greatly appreciated. Thanks for your time!
I also have basic touches on the screen that run functions
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let touch:UITouch = touches.first! as UITouch
let touchLocation = touch.location(in: self)
if playButton.contains(touchLocation) && proceed == true{
playSound1()
Ball.physicsBody?.affectedByGravity = true
proceed = false}
else if infoButton.contains(touchLocation) && proceed == true{
playSound1()
loadScene2()}
else {}
}