Adding inputstate extension

master
Nathan Adams 2012-06-03 15:42:25 -05:00
parent 4ba6fd89ee
commit 6f1d7e6d4d
1 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameStateManagement;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
namespace Axios.Engine.Extensions
{
public static class AxiosExtensions_InputState
{
// I got tired of always specifying Player one
//-- Nathan Adams [adamsna@datanethost.net] - 6/3/2012
/// <summary>
/// This checks if the key is pressed by player one
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static bool IsKeyPressed(this InputState input, Keys key)
{
PlayerIndex p;
return input.IsKeyPressed(key, PlayerIndex.One, out p);
}
public static bool IsButtonPressed(this InputState input, Buttons button)
{
PlayerIndex p;
return input.IsButtonPressed(button, PlayerIndex.One, out p);
}
public static bool IsNewKeyPress(this InputState input, Keys key)
{
PlayerIndex p;
return input.IsNewKeyPress(key, PlayerIndex.One, out p);
}
public static bool IsNewButtonPress(this InputState input, Buttons button)
{
PlayerIndex p;
return input.IsNewButtonPress(button, PlayerIndex.One, out p);
}
public static bool IsNewButtonRelease(this InputState input, Buttons button)
{
PlayerIndex p;
return input.IsNewButtonRelease(button, PlayerIndex.One, out p);
}
public bool IsNewKeyRelease(this InputState input, Keys key)
{
PlayerIndex p;
return input.IsNewKeyRelease(key, PlayerIndex.One, out p);
}
}
}