I want to do a pinch/zoom having the zoom start at the current scale. I have tried the following code:
@objc func pinchedView(recognizer:UIPinchGestureRecognizer) {
if (recognizer.state == .ended) {
lastScale = 1.0
return
}
let scale = 1.0 - (lastScale - recognizer.scale)
let zoomInAction = SKAction.scale(to: cameraNode.yScale + scale, duration: 0.25)
lastScale = recognizer.scale
cameraNode.run(zoomInAction)
}
The problem is that it keeps getting smaller and smaller no matter which way I pinch. How can I correct this?
I think you might instead want to initialize lastScale to 1.0 when your gesture begins.
Look at the accepted answer to this question.