0
public string[] ButtonList()
{
string[] buttons = { "A", "B", "Back", "BigButton", "etc..." }
return buttons;
}
private void EchoButtons()
{
for (int i = 0; i < ButtonList().Length; i++)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed)
{
// Echo the buttons
}
}
}
反正我有可以使用从字符串数组定义按钮? 例子(尽管这简化版,工作):
for (int i = 0; i < ButtonList().Length; i++)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.ButtonList()[i] == ButtonState.Pressed)
{
// Echo the buttons
}
}
编辑:我希望这是有道理的,我不知道我解释得很好。