简体   繁体   English

XNA游戏工作室Xbox控制器

[英]XNA game studio Xbox controller


I have a question about XNA. 我有一个关于XNA的问题。 Is it possible in XNA to read input from an Xbox controller pluged into my PC? 是否可以在XNA中读取插入我PC的Xbox控制器的输入? (I'm a beginner) (我是初学者)

I would appreciate a reply. 我很感激回复。

Yes. 是。 In the same fashion as Keyboard state and mouse state , XNA provides you with the Gamepad class which exposes the GetState method to control whatever you want in the game. Keyboard状态鼠标状态相同 ,XNA为您提供了Gamepad类,它暴露了GetState方法以控制游戏中您想要的任何内容。 One of the main differences is that the GetState method here asks you to provide the player index value (values 1 to 4) representing the player you want to read the info from. 其中一个主要区别是GetState方法要求您提供表示要从中读取信息的玩家的玩家索引值 (值1到4)。

Also, if you check the default code provided in the Update method, you will see that it is already been used to control a way to exit the game (by pressing the Back button if my memory doesn't lie to me). 此外,如果您检查Update方法中提供的默认代码,您将看到它已被用于控制退出游戏的方式(如果我的记忆不对我说谎,则按返回按钮)。

Keep in mind that if you want to use a wireless gamepad, you'll need a wireless receiver connected on your PC to connect to it. 请记住,如果您想使用无线游戏手柄,您需要在PC上连接无线接收器才能连接到它。

根据这个 ,您可以使用GamePad类从XBox360控制器读取输入,就像其他类型的游戏手柄一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM