I've implemented a zoom feature, but the nodes I use to move the player, arrows pointing in the direction the player moves, stay the same size and I can't figure out how to scale them proportionally, so if I zoom in, the buttons get smaller and move closer to the player to stay on screen, and vice versa when you zoom out.
Here's the code I wrote to allow zooming:
@objc func handlePinch(sender: UIPinchGestureRecognizer) {
guard sender.view != nil else { return }
if sender.state == .began || sender.state == .changed {
sender.view?.transform = (sender.view?.transform.scaledBy(x: sender.scale, y: sender.scale))!
sender.scale = 1.0
}
}
let pinch = UIPinchGestureRecognizer(target: self, action: #selector(handlePinch(sender:)))
view.addGestureRecognizer(pinch)
Are you using SpriteKit ?
If so you can probably work on camera node scale to implement "zoom" feature: https://developer.apple.com/documentation/spritekit/skcameranode/getting_started_with_a_camera
Apple's doc saying :
you should probably invert the sender scale value :
self.camera.xScale = -sender.scale