Two fingers zoom the map but the spot between them slides away
On a touch screen the person pinches to zoom and drags with the same two fingers, and the map should follow both like paper under the fingers. Zooming around the screen center feels wrong, and lifting one finger makes the view jump. Here is the calculation from the start of the gesture and the traps at its ends.
Why this works
A person pinches to keep one spot under their fingers. Measuring from where the gesture began, not from the last moment, avoids tiny errors piling up, and pinning that same spot under the new midpoint is exactly what the hand expects.
When not to use it
It does not fit games where the view must stay fixed or zoom only in set steps, such as a puzzle board that fits the screen. Use a zoom button, or fit the board to the window, instead of free pinching.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- 39 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Two fingers zoom the map but the spot between them slides away" (read_entry strategy-two-finger-pinch-and-pan) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP