XNA - 如何判断拇指棒是否被“抽动”在某个方向
API(3 或 4)中是否有任何内容可以告诉我操纵杆是否朝一个方向移动,就像在菜单中相当于按 DPad 上的某个方向一样? Buttons
枚举中似乎有一些 Thumbstick*
成员,但我找不到关于它们的合适文档。
只是想在我自己动手之前确保我没有遗漏一些明显的东西。谢谢!
Is there anything in the API (3 or 4) to tell me if the stick moved in one direction, as in a menu where it's equivalent to hitting a direction on the DPad? There appear to be some Thumbstick*
members in the Buttons
enum, but I can't find decent documentation on them.
Just want to make sure I'm not missing something obvious before I go and roll my own. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
没有 XNA 方法可以告诉您拇指操纵杆是否在该帧中“抽动”。
最简单的方法是存储旧的操纵杆状态。如果状态原本为零且现在非零,则它已被抽搐。
加法:
而不是检查状态是否为零且现在是否非零。您可以使用问题中提到的枚举中的拇指操纵杆按钮来确定操纵杆是否已“抽动”。在这种情况下,您将操纵杆视为 DPad,并且必须独立测试每个方向。下面的代码展示了这个方法:
There is no XNA method to tell you if a thumbstick was "twitched" this frame.
The easiest method is to store the old thumbstick state. If the state was zero and is now non-zero, it has been twitched.
Addition:
Instead of checking if the state was zero and is now non-zero. You can use the thumbstick buttons from the enumeration you mention in your question to determine if the stick has been "twitched". In this case you are treating the stick like a DPad and have to test each direction independently. The following code shows this method:
Xbox 360 控制器上的摇杆可以像按钮一样“推入”,映射到 GamePadButtons.LeftStick 和 GamePadButtons.RightStick。这些显然不是您想要的。
以下是我用于检测任何方向上的“按下”的代码(其中
padLeftPushActive
存储在帧之间):修改此代码以使其检测应该相当简单只需按菜单所需的特定方向即可。
The thumbsticks on an Xbox 360 controller can be pushed "in" like buttons, which map to
GamePadButtons.LeftStick
andGamePadButtons.RightStick
. These are obviously not what you want.Here is the code that I use for detecting "presses" in any direction (where
padLeftPushActive
is stored between frames):It should be fairly simple to modify this so that it detects just presses in the particular directions necessary for your menu.
是 GamePadState.Thumbsticks您在寻找什么财产?
Is the GamePadState.Thumbsticks property what you're looking for?
这是我想出的解决方案,以防它对任何人有用:
Here's the solution I came up with, in case it's useful for anyone: