public bool IsNewKeyPress(Keys key, PlayerIndex? controllingPlayer,
out PlayerIndex playerIndex)
{
if (controllingPlayer.HasValue)
{
// Read input from the specified player.
playerIndex = controllingPlayer.Value; int i = (int)playerIndex; return (CurrentKeyboardStates[i].IsKeyDown(key) &&
LastKeyboardStates[i].IsKeyUp(key));
}
else
{
// Accept input from any player.
return (IsNewKeyPress(key, PlayerIndex.One, out playerIndex) ||
IsNewKeyPress(key, PlayerIndex.Two, out playerIndex) ||
IsNewKeyPress(key, PlayerIndex.Three, out playerIndex) ||
IsNewKeyPress(key, PlayerIndex.Four, out playerIndex));
}
}
我不明白else中的return。
不是说out关键字是让函数来初始化参数的吗。但是给playerindex赋值的语句在if中,如果没有按键按下,那么if不成立,在else中这个函数会不断的自己调用自己,同时playerindex无法得到值。
本人刚接触编程,不懂怎么学习,理解能力不强,
以上是我的理解,这种理解无疑是错的。希望接触过编程的前辈给指点一下。C#XNA编程
out PlayerIndex playerIndex)
{
if (controllingPlayer.HasValue)
{
// Read input from the specified player.
playerIndex = controllingPlayer.Value; int i = (int)playerIndex; return (CurrentKeyboardStates[i].IsKeyDown(key) &&
LastKeyboardStates[i].IsKeyUp(key));
}
else
{
// Accept input from any player.
return (IsNewKeyPress(key, PlayerIndex.One, out playerIndex) ||
IsNewKeyPress(key, PlayerIndex.Two, out playerIndex) ||
IsNewKeyPress(key, PlayerIndex.Three, out playerIndex) ||
IsNewKeyPress(key, PlayerIndex.Four, out playerIndex));
}
}
我不明白else中的return。
不是说out关键字是让函数来初始化参数的吗。但是给playerindex赋值的语句在if中,如果没有按键按下,那么if不成立,在else中这个函数会不断的自己调用自己,同时playerindex无法得到值。
本人刚接触编程,不懂怎么学习,理解能力不强,
以上是我的理解,这种理解无疑是错的。希望接触过编程的前辈给指点一下。C#XNA编程
解决方案 »
- c#通过在textbox中输入一个与datagridview列值相等内容,在datagridview选中该行数据显示出来?
- C#连接窗口问题
- lable的这个问题怎么解决
- 在C++使用TextOut 打印的坐标和C#使用PrintDocument的坐标为什么不一样
- 急。。。。有哪位朋友写过和扫描仪连接的东西没 ?能不能给个例子看看
- 高分请教问题,关于ComboBox的下拉项目的事
- 如何在表格中输入文字的时候保持不换行
- 中国法律规定一周上几天班呀,为什么徐州都是上六天班,周六上班却不算加班!
- vs.net哪里有下载!
- 匹配一个长度为 0 ~ 2000 的字符串的正则表达式要怎么写?
- 关于一个C#字符数组的问题
- 如何利用反射获取DropDownList控件的Items属性的FindByValue方法
没有值的情况下调用的IsNewKeyPress的controllingPlayer是有值的,所以不会死循环。