I have a Swift + SpriteKit application that loads SKSpriteNode onto a scene, registers a UIPinchGestureRecognizer and processes this gesture with a simple handler function, for example:
func zoom(_ sender: UIPinchGestureRecognizer) {
if map.frame.width >= 1408 && map.frame.width <= 3072 {
map.run(SKAction.scale(by: sender.scale, duration: 0))
}
print(map.frame.width)
}
However, the pinch will still have the size of the node sprite smaller than the specified limits, and then, when I try to pinch again, the handler suddenly recognizes the limits that I have placed, and do not allow and do not allow, a creepy gesture.
I tried to do the same with the recognizer scale attribute:
func zoom(_ sender: UIPinchGestureRecognizer) {
if sender.scale >= 0.9 && sender.scale <= 2.1 {
map.run(SKAction.scale(by: sender.scale, duration: 0))
}
print(map.frame.width)
}
but this is even weirder: the node sprite will stop decreasing with a pinch, but then it will become extremely massive with the inconvenience.
What is the right way to put borders on a joke gesture?