XNAのGSM
キットの入力の一部を見てみると、 の一部には2つのパラメータがあり、その他のパラメータは1つしかないことに気付きました。どうして?両者に違いはありますか?InputeStateメソッドのパラメータ
ここに2つの例があり、その後にコード全体へのリンクがあります。あなたが入力を探すために、特定の人物を指定したい場合は
/// <summary>
/// Checks for a "pause the game" input action.
/// The controllingPlayer parameter specifies which player to read
/// input for. If this is null, it will accept input from any player.
/// </summary>
public bool IsPauseGame(PlayerIndex? controllingPlayer)
{
PlayerIndex playerIndex;
return IsNewKeyPress(Keys.Escape, controllingPlayer, out playerIndex) ||
IsNewButtonPress(Buttons.Back, controllingPlayer, out playerIndex) ||
IsNewButtonPress(Buttons.Start, controllingPlayer, out playerIndex);
}
/// <summary>
/// Checks for a "menu cancel" input action.
/// The controllingPlayer parameter specifies which player to read input for.
/// If this is null, it will accept input from any player. When the action
/// is detected, the output playerIndex reports which player pressed it.
/// </summary>
public bool IsMenuCancel(PlayerIndex? controllingPlayer,
out PlayerIndex playerIndex)
{
return IsNewKeyPress(Keys.Escape, controllingPlayer, out playerIndex) ||
IsNewButtonPress(Buttons.B, controllingPlayer, out playerIndex) ||
IsNewButtonPress(Buttons.Back, controllingPlayer, out playerIndex);
}
@hexxagonalああ、両方に感謝します。 私の次の質問につながります。なぜ、いくつかのメソッドには1つのパラメータしかなく、他のメソッドには2しかないのですか?たとえば、IsMenuCancelはplayerIndexを出力しますが、isMenuUpは出力しません。 –
気にしないで、今あなたの完全な反応を見ます。以前は、あなたが書いた最初の2つの段落しか表示されませんでした。 –
私が編集した後、私は、開発者が情報以外のものを渡すことが適切であると思うケースがあると思います。 –