如何在Windows Phone 7中正确使用捏合功能来实现图片的放大/缩小效果?

发布于 2024-10-10 21:11:21 字数 318 浏览 3 评论 0原文

我正在尝试为我正在开发的 C#/XNA 游戏制作一个缩放系统。我所拥有的是相机位置、相机当前缩放(存储为浮点数)和 GestureSample 实例。

我抓住捏的两个位置并找到它们的中心以使我的放大点,然后如果该人尝试向内/向外捏,我会比较捏拖动动作发生之前和之后两个手指之间的距离长度来确定放大或缩小。

这种方法可行,但感觉有点浮动。我还没有弄清楚如何让它缩放到用户捏住的位置。我得到捏合的中间点,并尝试让相机在变焦变大时朝该方向移动,但有时相机会在 100% 变焦之前到达该点,有时则不会。

这都是算法问题,我想我想知道是否有一种我不知道的简单直接的方法可以做到这一点?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

就此别过 2024-10-17 21:11:21

您需要做的就是为相机提供一个目标位置(即捏合的“中点”)和加速度……然后,相机应该独立于捏合手势,向目标位置移动。这样,相机就会到达正确的位置......最重要的是,你的相机有了一个新功能:-)

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 :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文