How to use Pinch functionality correctly in Windows Phone 7 for zoom in/out effects from pictures?

StackOverflow https://stackoverflow.com/questions/4601478

  •  25-09-2019
  •  | 
  •  

문제

I'm trying to make a zoom system for a C#/XNA game I'm working on. What I have is the cameras position, the cameras current zoom (stored as a float) and the GestureSample instance.

I'm grabbing both positions of the pinchs and finding their center to make that my zoom in point, then if the person tries to pinch inwards/outwards I compare the length of the distance between the two fingers before and after the pinch drag action happened to determine to zoom in or out.

This kind of works but it feels a bit floaty. I also haven't figured out how I'm going to make it zoom towards a position where the user is pinching against. I get the middle point of the pinch and try to make the camera move in that direciton as the zoom gets larger but sometimes the camera gets to that point before 100% zoom and sometimes not ever.

It's all algorithm issues, I suppose what I want to know is if there is a simple straight forward way of doing this that I don't know of?

도움이 되었습니까?

해결책

All you need to do is give your camera a target location (ie. the "middle point" of your pinch), and an acceleration ... the camera should then, independently of the pinch gesture, move towards the target location. This way, the camera will just end up at the right spot ... and on top of that you have a new feature for your camera :-)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top