本文整理汇总了C#中GameStateManagement.InputState.IsMenuUp方法的典型用法代码示例。如果您正苦于以下问题:C# InputState.IsMenuUp方法的具体用法?C# InputState.IsMenuUp怎么用?C# InputState.IsMenuUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameStateManagement.InputState
的用法示例。
在下文中一共展示了InputState.IsMenuUp方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
{
// Move to the previous menu entry?
if (input.IsMenuUp(ControllingPlayer))
{
selectedEntry--;
if (selectedEntry < 0)
selectedEntry = menuEntries.Count - 1;
}
// Move to the next menu entry?
if (input.IsMenuDown(ControllingPlayer))
{
selectedEntry++;
if (selectedEntry >= menuEntries.Count)
selectedEntry = 0;
}
// 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.
PlayerIndex playerIndex;
if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
{
OnSelectEntry(selectedEntry, playerIndex);
}
else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
{
OnCancel(playerIndex);
}
}
示例2: HandleInput
/// <summary>
/// Responds to user input, changing the selected entry and accepting
/// or cancelling the menu.
/// </summary>
public override void HandleInput(InputState input)
{
// we cancel the current menu screen if the user presses the back button
PlayerIndex player;
if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
{
OnCancel(player);
}
if (input.IsMenuDown(ControllingPlayer)) {
if (selectedEntry < menuEntries.Count - 1)
selectedEntry += 1;
}
if (input.IsMenuUp(ControllingPlayer)) {
if (selectedEntry > 0)
selectedEntry -= 1;
}
if (input.IsMenuSelect(ControllingPlayer, out player)) {
menuEntries[selectedEntry].OnSelectEntry(player);
}
if (input.MouseGesture.HasFlag(MouseGestureType.LeftClick)) {
Point clickLocation = new Point((int)input.CurrentMousePosition.X, (int)input.CurrentMousePosition.Y);
// iterate the entries to see if any were tapped
for (int i = 0; i < menuEntries.Count; i++)
{
MenuEntry menuEntry = menuEntries[i];
if (GetMenuEntryHitBounds(menuEntry).Contains(clickLocation))
{
// select the entry. since gestures are only available on Windows Phone,
// we can safely pass PlayerIndex.One to all entries since there is only
// one player on Windows Phone.
OnSelectEntry(i, PlayerIndex.One);
}
}
}
if (input.MouseGesture.HasFlag(MouseGestureType.Move)) {
Point clickLocation = new Point((int)input.CurrentMousePosition.X, (int)input.CurrentMousePosition.Y);
// iterate the entries to see if any were tapped
for (int i = 0; i < menuEntries.Count; i++)
{
MenuEntry menuEntry = menuEntries[i];
if (GetMenuEntryHitBounds(menuEntry).Contains(clickLocation))
{
// select the entry. since gestures are only available on Windows Phone,
// we can safely pass PlayerIndex.One to all entries since there is only
// one player on Windows Phone.
//OnSelectEntry(i, PlayerIndex.One);
selectedEntry = i;
}
}
}
// look for any taps that occurred and select any entries that were tapped
foreach (GestureSample gesture in input.Gestures)
{
if (gesture.GestureType == GestureType.Tap)
{
// convert the position to a Point that we can test against a Rectangle
Point tapLocation = new Point((int)gesture.Position.X, (int)gesture.Position.Y);
// iterate the entries to see if any were tapped
for (int i = 0; i < menuEntries.Count; i++)
{
MenuEntry menuEntry = menuEntries[i];
if (GetMenuEntryHitBounds(menuEntry).Contains(tapLocation))
{
// select the entry. since gestures are only available on Windows Phone,
// we can safely pass PlayerIndex.One to all entries since there is only
// one player on Windows Phone.
OnSelectEntry(i, PlayerIndex.One);
}
}
}
}
}
示例3: HandleInput
/// <summary>
/// Responds to user input, changing the selected entry and accepting
/// or cancelling the menu.
/// </summary>
public override void HandleInput(InputState input)
{
// we cancel the current menu screen if the user presses the back button
PlayerIndex player;
if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
{
OnCancel(player);
}
#if WINDOWS
// Take care of Keyboard input
if (input.IsMenuUp(ControllingPlayer))
{
selectedEntry--;
if (selectedEntry < 0)
selectedEntry = menuEntries.Count - 1;
}
else if (input.IsMenuDown(ControllingPlayer))
{
selectedEntry++;
if (selectedEntry >= menuEntries.Count)
selectedEntry = 0;
}
else if (input.IsNewKeyPress(Keys.Enter, ControllingPlayer, out player) ||
input.IsNewKeyPress(Keys.Space, ControllingPlayer, out player))
{
OnSelectEntry(selectedEntry, player);
}
MouseState state = Mouse.GetState();
if (state.LeftButton == ButtonState.Released)
{
if (isMouseDown)
{
isMouseDown = false;
// convert the position to a Point that we can test against a Rectangle
Point clickLocation = new Point(state.X, state.Y);
// iterate the entries to see if any were tapped
for (int i = 0; i < menuEntries.Count; i++)
{
MenuEntry menuEntry = menuEntries[i];
if (menuEntry.Destination.Contains(clickLocation))
{
// Select the entry. since gestures are only available on Windows Phone,
// we can safely pass PlayerIndex.One to all entries since there is only
// one player on Windows Phone.
OnSelectEntry(i, PlayerIndex.One);
}
}
}
}
else if (state.LeftButton == ButtonState.Pressed)
{
isMouseDown = true;
// convert the position to a Point that we can test against a Rectangle
Point clickLocation = new Point(state.X, state.Y);
// iterate the entries to see if any were tapped
for (int i = 0; i < menuEntries.Count; i++)
{
MenuEntry menuEntry = menuEntries[i];
if (menuEntry.Destination.Contains(clickLocation))
selectedEntry = i;
}
}
#elif XBOX
// Take care of Gamepad input
if (input.IsMenuUp(ControllingPlayer))
{
selectedEntry--;
if (selectedEntry < 0)
selectedEntry = menuEntries.Count - 1;
}
else if (input.IsMenuDown(ControllingPlayer))
{
selectedEntry++;
if (selectedEntry >= menuEntries.Count)
selectedEntry = 0;
}
else if (input.IsNewButtonPress(Buttons.A, ControllingPlayer, out player))
OnSelectEntry(selectedEntry, player);
#elif WINDOWS_PHONE
// look for any taps that occurred and select any entries that were tapped
foreach (GestureSample gesture in input.Gestures)
{
if (gesture.GestureType == GestureType.Tap)
//.........这里部分代码省略.........
示例4: HandleInput
public void HandleInput(InputState input)
{
int oldSelected = selected;
int oldLibrary = libraryIndex;
if (input.IsMenuDown(screen.ControllingPlayer))
{
if (selected < library.Count - 1)
{
++selected;
if (selected == numEntries + index)
{
++index;
}
loadAroundIndex(selected);
}
}
if (input.IsMenuUp(screen.ControllingPlayer))
{
if (selected > 0)
{
--selected;
if (selected == index - 1)
{
--index;
}
loadAroundIndex(selected);
}
}
PlayerIndex player;
if (input.IsNewButtonPress(Buttons.X, screen.ControllingPlayer, out player))
{
MediaPlayer.Play(library[selected]);
}
if (input.IsNewButtonPress(Buttons.LeftShoulder, screen.ControllingPlayer, out player) ||
input.IsNewKeyPress(Keys.Left, screen.ControllingPlayer, out player))
{
if (libraryIndex > 0)
{
--libraryIndex;
mediaSourceName = MediaSource.GetAvailableMediaSources()[libraryIndex].Name;
library = new MediaLibrary(MediaSource.GetAvailableMediaSources()[libraryIndex]).Songs;
index = 0;
selected = 0;
initializeSongDataArray();
}
}
if (input.IsNewButtonPress(Buttons.RightShoulder, screen.ControllingPlayer, out player) ||
input.IsNewKeyPress(Keys.Right, screen.ControllingPlayer, out player))
{
if (libraryIndex < MediaSource.GetAvailableMediaSources().Count - 1)
{
++libraryIndex;
mediaSourceName = MediaSource.GetAvailableMediaSources()[libraryIndex].Name;
library = new MediaLibrary(MediaSource.GetAvailableMediaSources()[libraryIndex]).Songs;
index = 0;
selected = 0;
initializeSongDataArray();
}
}
if (input.IsNewButtonPress(Buttons.RightTrigger, screen.ControllingPlayer, out player))
{
if (library.Count > 0)
{
char c = '0';
// Skip ahead artist letter
if (SongDataArray[selected].Artist.Length > 0)
{
c = SongDataArray[selected].Artist.ToLower()[0];
}
int newIndex;
for (newIndex = selected; newIndex < library.Count; ++newIndex)
{
loadAroundIndex(newIndex);
if (SongDataArray[newIndex].Artist.Length == 0)
continue;
if (SongDataArray[newIndex].Artist.ToLower()[0] != c)
break;
}
selected = Math.Min(newIndex, library.Count - 1);
index = selected;
}
}
if (input.IsNewButtonPress(Buttons.LeftTrigger, screen.ControllingPlayer, out player))
{
if (library.Count > 0)
{
char c = 'z';
// Skip back artist letter
if (SongDataArray[selected].Artist.Length > 0)
{
c = SongDataArray[selected].Artist.ToLower()[0];
}
int newIndex;
//.........这里部分代码省略.........
示例5: HandleInput
/// <summary>
/// Responds to user input, changing the selected entry and accepting
/// or cancelling the menu.
/// </summary>
public override void HandleInput(InputState input)
{
var touch = input.TouchState;
var rect = new Rectangle(0,0,100,30);
if (touch.Count == 1 ) {
for (int i = 0; i < menuEntries.Count; i++){
rect.X = (int)menuEntries[i].Position.X;
rect.Y = (int)menuEntries[i].Position.Y;
selectedEntry = i;
if (rect.Contains((int)touch[0].Position.X, (int)touch[0].Position.Y)){
OnSelectEntry(selectedEntry, 0);
break;
}
}
}
// Move to the previous menu entry?
if (input.IsMenuUp(ControllingPlayer))
{
selectedEntry--;
if (selectedEntry < 0)
selectedEntry = menuEntries.Count - 1;
}
// Move to the next menu entry?
if (input.IsMenuDown(ControllingPlayer))
{
selectedEntry++;
if (selectedEntry >= menuEntries.Count)
selectedEntry = 0;
}
// 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.
PlayerIndex playerIndex;
if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
{
OnSelectEntry(selectedEntry, playerIndex);
}
else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
{
OnCancel(playerIndex);
}
}
示例6: 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);
}
}
}
}
示例7: 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();
}
}