本文整理汇总了C#中InputManager.IsMenuCancel方法的典型用法代码示例。如果您正苦于以下问题:C# InputManager.IsMenuCancel方法的具体用法?C# InputManager.IsMenuCancel怎么用?C# InputManager.IsMenuCancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputManager
的用法示例。
在下文中一共展示了InputManager.IsMenuCancel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleInput
/// <summary>
/// Responds to user input, accepting or cancelling the message box.
/// </summary>
public override void HandleInput(GameTime gameTime, InputManager input)
{
PlayerIndex playerIndex;
// 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 our Accepted and
// Cancelled events, so they can tell which player triggered them.
if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
{
// Raise the accepted event, then exit the message box.
if (Accepted != null)
Accepted(this, new PlayerIndexEventArgs(playerIndex));
ExitScreen();
}
else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
{
// Raise the cancelled event, then exit the message box.
if (Cancelled != null)
Cancelled(this, new PlayerIndexEventArgs(playerIndex));
ExitScreen();
}
}
示例2: HandleInput
public override void HandleInput(GameTime gameTime, InputManager input)
{
PlayerIndex dummyPlayerIndex;
if (input.IsMenuCancel(ControllingPlayer, out dummyPlayerIndex))
{
ExitScreen();
return;
}
// handle selecting a save game
if (input.IsMenuSelect(ControllingPlayer, out dummyPlayerIndex) &&
(mSaveGameDescriptions != null))
{
switch (mMode)
{
case SaveLoadScreenMode.Load:
if ((mCurrentSlot >= 0) &&
(mCurrentSlot < mSaveGameDescriptions.Count) &&
(mSaveGameDescriptions[mCurrentSlot] != null))
{
if (GameResources.GameDossier != null)
{
MessageBoxScreen messageBoxScreen = new MessageBoxScreen("Are you sure you want to load this game?");
messageBoxScreen.Accepted += ConfirmLoadMessageBoxAccepted;
ScreenManager.AddScreen(messageBoxScreen, ControllingPlayer);
}
else
{
ConfirmLoadMessageBoxAccepted(null, EventArgs.Empty);
}
}
break;
case SaveLoadScreenMode.Save:
if ((mCurrentSlot >= 0) &&
(mCurrentSlot <= mSaveGameDescriptions.Count))
{
if (mCurrentSlot == mSaveGameDescriptions.Count)
{
ConfirmSaveMessageBoxAccepted(null, EventArgs.Empty);
}
else
{
MessageBoxScreen messageBoxScreen = new MessageBoxScreen("Are you sure you want to overwrite this save game?");
messageBoxScreen.Accepted += ConfirmSaveMessageBoxAccepted;
ScreenManager.AddScreen(messageBoxScreen, ControllingPlayer);
}
}
break;
}
}
// handle deletion
else if (input.IsMenuDelete(ControllingPlayer) &&
(mSaveGameDescriptions != null))
{
if ((mCurrentSlot >= 0) &&
(mCurrentSlot < mSaveGameDescriptions.Count) &&
(mSaveGameDescriptions[mCurrentSlot] != null))
{
MessageBoxScreen messageBoxScreen = new MessageBoxScreen(
"Are you sure you want to delete this save game?");
messageBoxScreen.Accepted += ConfirmDeleteMessageBoxAccepted;
ScreenManager.AddScreen(messageBoxScreen, ControllingPlayer);
}
}
// handle cursor-down
else if (input.IsMenuDown(ControllingPlayer) &&
(mSaveGameDescriptions != null))
{
int maximumSlot = mSaveGameDescriptions.Count;
if (mMode == SaveLoadScreenMode.Save)
{
maximumSlot = Math.Min(maximumSlot + 1,
MaximumSaveGameDescriptions);
}
if (mCurrentSlot < maximumSlot - 1)
{
mCurrentSlot++;
}
}
// handle cursor-up
else if (input.IsMenuUp(ControllingPlayer) &&
(mSaveGameDescriptions != null))
{
if (mCurrentSlot >= 1)
{
mCurrentSlot--;
}
}
}
示例3: HandleInput
/// <summary>
/// Responds to user input, changing the selected entry and accepting
/// or cancelling the menu.
/// </summary>
public override void HandleInput(GameTime gameTime, InputManager input)
{
PlayerIndex playerIndex;
if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
{
OnCancel(playerIndex);
return;
}
menuEntries[selectedEntry].HandleInput(gameTime, input, ControllingPlayer);
// 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;
}
}