本文整理汇总了C#中GameStateManagement.InputState类的典型用法代码示例。如果您正苦于以下问题:C# InputState类的具体用法?C# InputState怎么用?C# InputState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InputState类属于GameStateManagement命名空间,在下文中一共展示了InputState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HandleInput
public override void HandleInput(GameTime gameTime, InputState input)
{
KeyboardState keyboardState = input.CurrentKeyboardState;
KeyboardState lastKeyboardState = input.LastKeyboardState;
if ((keyboardState.IsKeyDown(Keys.Up) && !lastKeyboardState.IsKeyDown(Keys.Up)) || (keyboardState.IsKeyDown(Keys.W) && !lastKeyboardState.IsKeyDown(Keys.W)))
{
selectedEntry--;
if (selectedEntry < 0)
selectedEntry = menuEntries.Count - 1;
}
if (keyboardState.IsKeyDown(Keys.Down) && !lastKeyboardState.IsKeyDown(Keys.Down) || (keyboardState.IsKeyDown(Keys.S) && !lastKeyboardState.IsKeyDown(Keys.S)))
{
selectedEntry++;
if (selectedEntry >= menuEntries.Count)
selectedEntry = 0;
}
if ((keyboardState.IsKeyDown(Keys.Space) && !lastKeyboardState.IsKeyDown(Keys.Space)) || (keyboardState.IsKeyDown(Keys.Enter) && !lastKeyboardState.IsKeyDown(Keys.Enter)))
{
OnSelectEntry(selectedEntry);
}
else if (keyboardState.IsKeyDown(Keys.Escape) && !lastKeyboardState.IsKeyDown(Keys.Escape))
{
OnCancel();
}
}
开发者ID:BenFradet,项目名称:OldXnaStuff,代码行数:27,代码来源:MenuScreen.cs
示例2: Evaluate
/// <summary>
/// Evaluates the action against a given inputState.
/// </summary>
/// <param name="state">The InputState to test for the action.</param>
/// <param name="controllingPlayer">The player to test, or null to allow any player.</param>
/// <param name="player">If controllingPlayer is null, this is the player that performed the action.</param>
/// <returns>True if the action occured, false otherwise.</returns>
public bool Evaluate(InputState state, PlayerIndex? controllingPlayer, out PlayerIndex player)
{
// Figure out which delegate methods to map from the state which takes care of our "newPressOnly" logic
ButtonPress buttonTest;
KeyPress keyTest;
if (newPressOnly)
{
buttonTest = state.IsNewButtonPress;
keyTest = state.IsNewKeyPress;
}
else
{
buttonTest = state.IsButtonPressed;
keyTest = state.IsKeyPressed;
}
// Now we simply need to invoke the appropriate methods for each button and key in our collections
foreach (Buttons button in buttons)
{
if (buttonTest(button, controllingPlayer, out player))
return true;
}
foreach (Keys key in keys)
{
if (keyTest(key, controllingPlayer, out player))
return true;
}
// If we got here, the action is not matched.
player = PlayerIndex.One;
return false;
}
开发者ID:jamesyp,项目名称:MazeGame,代码行数:39,代码来源:InputAction.cs
示例3: HandleInput
public override void HandleInput(AxiosGameScreen gameScreen, InputState input, GameTime gameTime)
{
base.HandleInput(gameScreen, input, gameTime);
//if (gameScreen.Console != null && gameScreen.Console.Active)
// return;
PlayerIndex p;
Animate = false;
if (input.IsKeyPressed(Keys.A, PlayerIndex.One, out p))
{
Move(Direction.Left);
}
if (input.IsKeyPressed(Keys.W, PlayerIndex.One, out p) && !jumping)
{
Move(Direction.Up);
jumping = true;
}
//else if (input.IsKeyPressed(Keys.S, PlayerIndex.One, out p))
//{
// Move(Direction.Down);
//}
if (input.IsKeyPressed(Keys.D, PlayerIndex.One, out p))
{
Move(Direction.Right);
}
else
{
//BodyPart.LinearVelocity = Vector2.Zero;
}
}
开发者ID:nadams810,项目名称:axiosplatformer,代码行数:31,代码来源:Player.cs
示例4: HandleInput
public override void HandleInput(InputState input)
{
if (isLoading == true)
{
base.HandleInput(input);
return;
}
foreach (var gesture in input.Gestures)
{
if (gesture.GestureType == GestureType.Tap)
{
// Create a new instance of the gameplay screen
gameplayScreen = new GameplayScreen();
gameplayScreen.ScreenManager = ScreenManager;
// Start loading the resources in additional thread
thread = new System.Threading.Thread(
new System.Threading.ThreadStart(gameplayScreen.LoadAssets));
isLoading = true;
thread.Start();
}
}
base.HandleInput(input);
}
开发者ID:elixir67,项目名称:Sandbox,代码行数:26,代码来源:InstructionsScreen.cs
示例5: OnInput
public override void OnInput(InputState input)
{
Keys[] pressedKeys = input.NewPressedKeys().ToArray();
for (int i = pressedKeys.Length - 1; i >= 0; i--)
{
Keys pressedKey = pressedKeys[i];
int pressedKeyNum = (int)pressedKey;
if (pressedKey >= Keys.A && pressedKey <= Keys.Z)
{
Value += (char)((input.IsKeyPressed(Keys.LeftShift) || input.IsKeyPressed(Keys.RightShift)) ? pressedKeyNum : pressedKeyNum + 32);
}
else if (pressedKey == Keys.Space) Value += " ";
else if (pressedKey == Keys.Back && Value.Length > 0) Value = Value.Substring(0, Value.Length - 1);
//if (input.Mapping.Chars().ContainsKey(pressedKey)) Value += input.IsKeyPress(input.Mapping.Shift) ? input.Mapping.Chars()[pressedKey] : (char)(input.Mapping.Chars()[pressedKey] + 32);
//else if (input.Mapping.Numbers().ContainsKey(pressedKey)) Value += input.Mapping.Numbers()[pressedKey].ToString();
//else if (pressedKey == input.Mapping.Hyphen || pressedKey == Key.Minus) Value += input.IsKeyPress(Key.ShiftLeft) ? "_" : "-";
//else if (pressedKey == input.Mapping.Point) Value += input.IsKeyPress(Key.ShiftLeft) ? ":" : ".";
//else if (pressedKey == input.Mapping.Comma) Value += input.IsKeyPress(Key.ShiftLeft) ? ";" : ",";
//else if (pressedKey == input.Mapping.Space) Value += " ";
//else if (pressedKey == input.Mapping.Back && Value.Length > 0) Value = Value.Substring(0, Value.Length - 1);
}
base.OnInput(input);
}
开发者ID:Xellss,项目名称:RougyMon,代码行数:25,代码来源:TextMenuEntry.cs
示例6: HandleInput
/// <summary>
/// Lets the game respond to player input. Unlike the Update method,
/// this will only be called when the gameplay screen is active.
/// </summary>
public override void HandleInput(InputState input)
{
if (input == null)
throw new ArgumentNullException("input");
// Look up inputs for the active player profile.
int playerIndex = (int)ControllingPlayer.Value;
KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex];
GamePadState gamePadState = input.CurrentGamePadStates[playerIndex];
// The game pauses either if the user presses the pause button, or if
// they unplug the active gamepad. This requires us to keep track of
// whether a gamepad was ever plugged in, because we don't want to pause
// on PC if they are playing with a keyboard and have no gamepad at all!
bool gamePadDisconnected = !gamePadState.IsConnected && input.GamePadWasConnected[playerIndex];
if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected)
{
ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer);
}
else
{
xspace.HandleInput(keyboardState, gamePadState);
}
}
开发者ID:scenex,项目名称:XSpaceEngine,代码行数:30,代码来源:GameplayScreen.cs
示例7: HandleInput
/// <summary>
/// Lets the game respond to player input. Unlike the Update method,
/// this will only be called when the main menu screen is active.
/// </summary>
public override void HandleInput(InputState input)
{
if (input == null)
throw new ArgumentNullException("input");
base.HandleInput(input);
}
开发者ID:ckelner,项目名称:proto-lemming-death,代码行数:11,代码来源:MainMenuScreen.cs
示例8: HandleInput
public override void HandleInput(GameTime gameTime, InputState input)
{
// Read in our gestures
foreach(GestureSample gesture in input.Gestures) {
if (single) { // if it is single player, just start the game
if(Configuration.GAME_TEST) {
SwitchScreen(Configuration.DEF_GAME);
} else {
SwitchScreen(game.ScreenType);
}
return;
}
if (gesture.GestureType == GestureType.Tap && !done) {
done = true;
text = "Waiting for other players...";
Sync((JArray data, double rand) => {
timeLeftTimer.Dispose(); // dispose of the timer so we don't decrement the time anymore
if(Configuration.GAME_TEST) {
SwitchScreen(Configuration.DEF_GAME);
} else {
SwitchScreen(game.ScreenType);
}
}, "tutorial", 13); // give other players 13 seconds to continue
}
}
base.HandleInput(gameTime, input);
}
开发者ID:kktseng,项目名称:CritterCampClient,代码行数:30,代码来源:TutorialScreen.cs
示例9: HandleInput
public override void HandleInput(InputState input)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
//Go back to the previous screen if the player presses the back button
if (input.IsPauseGame(null))
{
Exit();
}
// Return to the main menu when a tap gesture is recognized
if (input.Gestures.Count > 0)
{
GestureSample sample = input.Gestures[0];
if (sample.GestureType == GestureType.Tap)
{
Exit();
input.Gestures.Clear();
}
}
}
开发者ID:nganthony,项目名称:Space-Catch,代码行数:25,代码来源:TutorialScreen.cs
示例10: HandleInput
public override void HandleInput(InputState input)
{
base.HandleInput(input);
for (int i = 0; i < 6; i++)
{
if (Settings.players[i].active == false && input.IsPlayerTurnLeft((PlayerNumber)i))
{
Settings.players[i].active = true;
Settings.Game.num_players++;
}
else if (Settings.players[i].active == true && input.IsPlayerTurnRight((PlayerNumber)i))
{
Settings.players[i].active = false;
Settings.Game.num_players--;
}
}
if (Settings.Game.num_players > 1 && input.MenuSelect)
{
LoadingScreen.Load(ScreenManager, true, new GamePlayScreen());
ExitScreen();
}
if (input.PauseGame)
{
const string message = "Are you sure you want to quit this game?";
MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message);
confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;
ScreenManager.AddScreen(confirmQuitMessageBox);
}
}
开发者ID:LarsTijsmans,项目名称:curve-game,代码行数:32,代码来源:PreGameScreen.cs
示例11: HandleInput
public override void HandleInput(InputState input)
{
PlayerIndex player;
if (input.IsNewButtonPress(Buttons.Y, ControllingPlayer, out player))
{
#if XBOX
Debug.Assert (ControllingPlayer != null);
HighScores2.GoLoad(ControllingPlayer ?? PlayerIndex.One);
#else
HighScores2.DoWindowsLoadGame();
#endif
ScreenManager.AddScreen(new HighScoreScreen(), ControllingPlayer);
}
if (input.IsMenuCancel(ControllingPlayer, out player))
{
MediaPlayer.Stop();
}
songSelectionBox.HandleInput(input);
if (songSelectionBox.SongCount <= 0 &&
input.IsNewButtonPress(Buttons.A, null, out player))
{
return;
}
base.HandleInput(input);
}
开发者ID:kmatzen,项目名称:EECS-494-Final-Project,代码行数:29,代码来源:SongSelectionScreen.cs
示例12: Evaluate
public bool Evaluate(InputState state, PlayerIndex? controllingPlayer, out PlayerIndex player)
{
ButtonPress buttonTest;
KeyPress keyTest;
if (newPressOnly)
{
buttonTest = state.IsNewButtonPress;
keyTest = state.IsNewKeyPress;
}
else
{
buttonTest = state.IsButtonPressed;
keyTest = state.IsKeyPressed;
}
foreach (Buttons button in buttons)
{
if (buttonTest(button, controllingPlayer, out player))
return true;
}
foreach (Keys key in keys)
{
if (keyTest(key, controllingPlayer, out player))
return true;
}
player = PlayerIndex.One;
return false;
}
开发者ID:Xellss,项目名称:RougyMon,代码行数:27,代码来源:InputAction.cs
示例13: Button
/// <summary>
/// Creates a new instance of the <see cref="Button"/> class.
/// </summary>
/// <param name="regularTexture">The name of the button's texture.</param>
/// <param name="pressedTexture">The name of the texture to display when the
/// button is pressed.</param>
/// <param name="input">A <see cref="GameStateManagement.InputState"/> object
/// which can be used to retrieve user input.</param>
/// <param name="cardGame">The associated card game.</param>
/// <remarks>Texture names are relative to the "Images" content
/// folder.</remarks>
public Button(string regularTexture, string pressedTexture, InputState input,
CardsGame cardGame)
: base(cardGame, null)
{
this.input = input;
this.regularTexture = regularTexture;
this.pressedTexture = pressedTexture;
}
开发者ID:liwq-net,项目名称:SilverSprite,代码行数:19,代码来源:Button.cs
示例14: ScreenManager
/// <summary>
/// Constructs a new screen manager component.
/// </summary>
public ScreenManager(Game game)
: base(game)
{
// we must set EnabledGestures before we can query for them, but
// we don't assume the game wants to read them.
TouchPanel.EnabledGestures = GestureType.None;
this.input = new InputState(this);
}
开发者ID:nadams810,项目名称:axiosengine,代码行数:11,代码来源:ScreenManager.cs
示例15: HandleInput
public override void HandleInput(InputState input)
{
// look for any taps that occurred and select any entries that were tapped
foreach (GestureSample gesture in input.Gestures)
{
//check against the panel
}
base.HandleInput(input);
}
开发者ID:agentcox,项目名称:NodeHackEX-xna,代码行数:9,代码来源:LevelSelectScreen.cs
示例16: HandleInput
/// <summary>
/// Handle user input.
/// </summary>
/// <param name="input">User input information.</param>
public override void HandleInput(InputState input)
{
if (input.IsPauseGame(null))
{
PauseCurrentGame();
}
base.HandleInput(input);
}
开发者ID:Ezekoka,项目名称:MonoGame-StarterKits,代码行数:13,代码来源:GameplayScreen.cs
示例17: HandleInput
public override void HandleInput (InputState input)
{
if (isLoading == true)
{
#if ANDROID || IOS || LINUX || WINDOWS
// Exit the screen and show the gameplay screen
// with pre-loaded assets
ExitScreen ();
ScreenManager.AddScreen (gameplayScreen, null);
#endif
base.HandleInput (input);
return;
}
PlayerIndex player;
if (input.IsNewKeyPress (Microsoft.Xna.Framework.Input.Keys.Space, ControllingPlayer, out player) ||
input.IsNewKeyPress (Microsoft.Xna.Framework.Input.Keys.Enter, ControllingPlayer, out player) ||
input.MouseGesture.HasFlag(MouseGestureType.LeftClick) ||
input.IsNewButtonPress (Microsoft.Xna.Framework.Input.Buttons.Start, ControllingPlayer, out player)) {
// Create a new instance of the gameplay screen
gameplayScreen = new GameplayScreen ();
gameplayScreen.ScreenManager = ScreenManager;
// Start loading the resources in additional thread
#if !LINUX && !WINDOWS
#if MACOS
// create a new thread using BackgroundWorkerThread as method to execute
thread = new Thread (LoadAssetsWorkerThread as ThreadStart);
#else
thread = new System.Threading.Thread (new System.Threading.ThreadStart (gameplayScreen.LoadAssets));
#endif
isLoading = true;
// start it
thread.Start ();
#else
isLoading = true;
#endif
}
foreach (var gesture in input.Gestures) {
if (gesture.GestureType == GestureType.Tap) {
// Create a new instance of the gameplay screen
gameplayScreen = new GameplayScreen ();
gameplayScreen.ScreenManager = ScreenManager;
#if ANDROID || IOS || LINUX || WINDOWS
isLoading = true;
#else
// Start loading the resources in additional thread
thread = new System.Threading.Thread (new System.Threading.ThreadStart (gameplayScreen.LoadAssets));
isLoading = true;
thread.Start ();
#endif
}
}
base.HandleInput (input);
}
开发者ID:jlyonsmith,项目名称:MonoGame-Samples,代码行数:57,代码来源:InstructionsScreen.cs
示例18: BetGameComponent
/// <summary>
/// Creates a new instance of the <see cref="BetGameComponent"/> class.
/// </summary>
/// <param name="players">A list of participating players.</param>
/// <param name="input">An instance of
/// <see cref="GameStateManagement.InputState"/> which can be used to
/// check user input.</param>
/// <param name="theme">The name of the selcted card theme.</param>
/// <param name="cardGame">An instance of <see cref="CardsGame"/> which
/// is the current game.</param>
public BetGameComponent(List<Player> players, InputState input,
string theme, CardsGame cardGame)
: base(cardGame.Game)
{
this.players = players;
this.theme = theme;
this.cardGame = cardGame;
this.input = input;
chipsAssets = new Dictionary<int, Texture2D>();
}
开发者ID:liwq-net,项目名称:SilverSprite,代码行数:20,代码来源:BetGameComponent.cs
示例19: HandleInput
public override void HandleInput(GameTime gameTime, InputState input)
{
//input.
if (input.CurrentKeyboardStates[0].GetPressedKeys().Length > 0 ||
input.CurrentGamePadStates[0].IsButtonDown(Buttons.A | Buttons.Start | Buttons.Back) ||
input.MouseState.LeftButton == ButtonState.Pressed)
{
_duration = TimeSpan.Zero;
}
}
开发者ID:nadams810,项目名称:axiosengine,代码行数:10,代码来源:LogoScreen.cs
示例20: HandleInput
public override void HandleInput(InputState input)
{
PlayerIndex player;
if (input.IsMenuSelect(null, out player))
{
exit = true;
ControllingPlayer = player;
}
base.HandleInput(input);
}
开发者ID:kmatzen,项目名称:EECS-494-Final-Project,代码行数:10,代码来源:TitleScreen.cs
注:本文中的GameStateManagement.InputState类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论