本文整理汇总了C#中GameStateManagement.InputState.IsMenuRight方法的典型用法代码示例。如果您正苦于以下问题:C# InputState.IsMenuRight方法的具体用法?C# InputState.IsMenuRight怎么用?C# InputState.IsMenuRight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameStateManagement.InputState
的用法示例。
在下文中一共展示了InputState.IsMenuRight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleInput
/// <summary>
/// Responds to user input, changing the selected entry and accepting
/// or cancelling the menu.
/// </summary>
public override void HandleInput(InputState input)
{
if (input.IsMenuCancel())
{
OnCancel(null, null);
}
if (input.IsMenuUp())
{
selectedEntry--;
if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1;
while (!menuEntries[selectedEntry].Enabled)
{
selectedEntry--;
if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1;
}
}
if (input.IsMenuDown())
{
selectedEntry++;
if (selectedEntry >= menuEntries.Count) selectedEntry = 0;
while (!menuEntries[selectedEntry].Enabled)
{
selectedEntry++;
if (selectedEntry >= menuEntries.Count) selectedEntry = 0;
}
}
if (input.IsMenuLeft()) menuEntries[selectedEntry].Left();
if (input.IsMenuRight()) menuEntries[selectedEntry].Right();
if (input.IsMenuSelect()) OnSelectEntry(selectedEntry);
if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1;
if (selectedEntry >= menuEntries.Count) selectedEntry = 0;
Point mouseLocation = ScreenManager.ScaledMousePos;
for (int i = 0; i < menuEntries.Count; i++)
{
MenuEntry menuEntry = menuEntries[i];
if (GetMenuEntryHitBounds(menuEntry).Contains(mouseLocation))
{
selectedEntry = i;
// Mouse left click?
if (input.CurrentMouseState.LeftButton == ButtonState.Released && input.LastMouseState.LeftButton == ButtonState.Pressed)
{
menuEntry.Click(mouseLocation.X, mouseLocation.Y);
}
}
}
}
示例2: HandleInput
/// <summary>
/// Responds to user input, changing the selected entry and accepting
/// or cancelling the menu.
/// </summary>
public override void HandleInput(InputState input)
{
// Move to the previous menu entry?
if (input.IsMenuUp(ControllingPlayer))
{
keyPos.Y--;
if (keyPos.Y < 0)
{
keyPos.Y = keys.Length - 1;
}
}
// Move to the next menu entry?
if (input.IsMenuDown(ControllingPlayer))
{
keyPos.Y++;
if (keyPos.Y > keys.Length-1)
{
keyPos.Y = 0;
}
}
PlayerIndex playerIndex;
if (input.IsMenuRight(ControllingPlayer))
{
keyPos.X++;
if (keyPos.X > keys[(int)keyPos.Y].Length - 1)
{
keyPos.X = 0;
}
}
if (input.IsMenuLeft(ControllingPlayer))
{
keyPos.X--;
if (keyPos.X < 0)
{
keyPos.X = keys[(int)keyPos.Y].Length - 1;
}
}
// Move to the next menu entry?
// public bool IsNewButtonPress(Buttons button, PlayerIndex? controllingPlayer,
// out PlayerIndex playerIndex)
if ( input.IsNewButtonPress(Buttons.Y,ControllingPlayer, out playerIndex) )
{
playerNameChars[selectedEntry] = ' ';
selectedEntry = Math.Min(selectedEntry + 1, numNameChars - 1);
playerNameMenuEntry.Text = (new string(playerNameChars, 0, playerNameChars.Length));
}
// Accept or cancel the menu? We pass in our ControllingPlayer, which may
// either be null (to accept input from any player) or a specific index.
// If we pass a null controlling player, the InputState helper returns to
// us which player actually provided the input. We pass that through to
// OnSelectEntry and OnCancel, so they can tell which player triggered them.
if (input.IsNewButtonPress(Buttons.A, ControllingPlayer, out playerIndex) )
{
OnSelectEntry(selectedEntry, playerIndex);
}
else if (input.IsNewButtonPress(Buttons.B, ControllingPlayer, out playerIndex) ||
input.IsNewButtonPress(Buttons.X, ControllingPlayer, out playerIndex)
)
{
OnCancel(playerIndex);
}
else if (input.IsNewButtonPress(Buttons.Start, ControllingPlayer, out playerIndex))
{
CompleteEntry();
}
}