如何在 WP8 720p 设备上使用 Windows Phone XNA 游戏纠正 TouchPanel 偏移错误? [英] How can I correct TouchPanel offset bug with Windows Phone XNA game on WP8 720p devices?

查看:27
本文介绍了如何在 WP8 720p 设备上使用 Windows Phone XNA 游戏纠正 TouchPanel 偏移错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 WP8 720p 设备上运行的 XNA 应用程序(WP7 或 WP7.5 应用程序)将自动进行信箱化,因此 480x800 BackBuffer 大小保持不变(我假设是为了兼容性).

XNA apps (WP7 or WP7.5 apps) that run on a WP8 720p device will get automatically letterboxed so the 480x800 BackBuffer size stays the same (for compatibility I presume).

这没问题,只是 XNA 兼容层中似乎存在错误.触摸面板报告偏离顶部信箱空白区域大小的触摸位置.

This would be fine, except there appears to be a bug in the XNA compatibility layer. The TouchPanel reports touch locations that are off by the size of the top letterbox blank area.

这有两个问题:

  1. 用户的触摸似乎无法进行,从而使游戏玩法和菜单导航变得困难.
  2. 因为它在负方向关闭,所以用户根本无法触摸屏幕最底部的东西.

我尝试通过仅考虑 53/2 像素偏移来解决此问题(53 是缩放坐标中的额外空间总量,除以 2,因为它仅被一个信箱栏关闭 - 顶部的那个).这确实纠正了触摸位置,但由于 TouchPanel 内部将负值钳位为 0,这意味着游戏顶部仍然存在死区(因为 -22 到 -1 应转换为 0 到 22,但如果所有负输入值被限制为 0,然后信息丢失,负范围内的所有内容将始终转换为 22).

I tried working around the issue by just factoring in 53 / 2 pixel offset (53 is the total amount of extra space in scaled coordinate, divide by two because it is only off by one letterbox bar - the one on the top). This does correct the touch location, but because TouchPanel internally clamps negative values to 0, it means that there is still a dead zone at the top of the game (because -22 through -1 should be translated to 0 through 22, but if all negative input values are clamped to 0 then information is lost and everything in the negative range will translate to 22 always).

有没有人遇到过这个问题并找到了解决方法?

Has anyone run into this and found a way to work around it?

我什至尝试将 TouchPanel.DisplayHeight/Width 重置为设备的实际 720p 值,并且在下一帧更新时以某种方式重置为 480x800.

I'v even tried resetting the TouchPanel.DisplayHeight/Width to the actual 720p values of the device and somehow it gets reset to 480x800 by the next frame update.

推荐答案

我刚刚开始工作,需要很早就将 TouchPanel.DisplayHeight 设置为 853(如果您检测到您使用的是这些 720p 设备之一).我在 OnNavigatedTo 从 Silverlight 主页面执行此操作(实际上是 SL/XNA).

I just got this working, the TouchPanel.DisplayHeight needs to be set to 853 (if you detect you are on one of these 720p devices) very early. I do it at OnNavigatedTo from the main Silverlight page (this is SL/XNA actually).

接下来,您必须将每个触摸位置和手势位置偏移 + 53.0f/2.0f.

Next, you have to offset every touch location and gesture location by + 53.0f / 2.0f.

我不确定为什么这在之前不起作用,因为这是我上面提到的解决方案,但似乎不起作用,因为触摸板一直重置为 800 高度.

I'm not sure why this didn't work before, as this is the solution I mentioned above that didn't seem to work because TouchPanel kept resetting to 800 height.

但是,我在精简版(新的 SL/XNA 应用程序)和我的主要游戏应用程序中都使用了它.

But, I got it working in both a reduced repro (new SL/XNA app) and my main game app.

这篇关于如何在 WP8 720p 设备上使用 Windows Phone XNA 游戏纠正 TouchPanel 偏移错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆