本文整理汇总了C#中Microsoft.Xna.Framework.Input.KeyboardState.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# KeyboardState.Equals方法的具体用法?C# KeyboardState.Equals怎么用?C# KeyboardState.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Input.KeyboardState
的用法示例。
在下文中一共展示了KeyboardState.Equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: update
} // Gå animeringen hos spelaren
public Vector2 update(KeyboardState pressedKeys)
{
velocity.Y = 2;
velocity.X = 2;
#region movement
// om w och eller a,d är nertryck kan man gå snett. Kan springa max agility velocity. agilityAccel är hur snabbt man kan springa till max hastigheten agility
if (pressedKeys.IsKeyDown(Keys.W))
{
position.Y = position.Y -= velocity.Y;
}
if (pressedKeys.IsKeyDown(Keys.S))
{
position.Y = position.Y += velocity.Y;
}
if (pressedKeys.IsKeyDown(Keys.A))
{
position.X = position.X -= velocity.X;
}
if (pressedKeys.IsKeyDown(Keys.D))
{
position.X = position.X += velocity.X;
}
velocity.X = 0;
velocity.Y = 0;
#endregion
#region ChangeWeaponAndKillThisInstance
if (pressedKeys.Equals(Keys.D1)|| pressedKeys.Equals(Keys.D2)|| pressedKeys.Equals(Keys.D3))
{
if (pressedKeys.Equals(Keys.D1))
{
type = "bow";
}
else if (pressedKeys.Equals(Keys.D2))
{
type = "sword";
}
else if (pressedKeys.Equals(Keys.D3))
{
type = "staff";
}
game1.changeWeapon(type, thisType);
player = null;
}
#endregion
return position;
}
示例2: update
public void update(GameTime gametime, KeyboardState current, KeyboardState previous)
{
if (current.IsKeyDown(Keys.Enter) && previous.IsKeyUp(Keys.Enter))
{
evaluate(information);
information = "";
return;
}
if (!previous.Equals(current))
{
for (int i = 0; i < previous.GetPressedKeys().Length; i++)
{
bool notPressed = false;
for (int j = 0; j < current.GetPressedKeys().Length; j++)
{
if (current.GetPressedKeys()[j].Equals(previous.GetPressedKeys()[i]))
notPressed = true;
}
if (!notPressed)
{
if (previous.GetPressedKeys()[i].Equals(Keys.Space))
information += " ";
else if (previous.GetPressedKeys()[i].Equals(Keys.RightShift) ||
previous.GetPressedKeys()[i].Equals(Keys.LeftShift) ||
previous.GetPressedKeys()[i].Equals(Keys.RightAlt) ||
previous.GetPressedKeys()[i].Equals(Keys.LeftAlt) ||
previous.GetPressedKeys()[i].Equals(Keys.RightControl) ||
previous.GetPressedKeys()[i].Equals(Keys.LeftControl))
information += "";
else if (previous.GetPressedKeys()[i].Equals(Keys.OemComma))
information += ",";
else if (previous.GetPressedKeys()[i].Equals(Keys.OemPeriod))
information += ".";
else if (previous.GetPressedKeys()[i].Equals(Keys.OemQuestion))
information += "?";
else if (previous.GetPressedKeys()[i].Equals(Keys.OemMinus))
information += "-";
else if (previous.GetPressedKeys()[i].Equals(Keys.Back))
{
if (information.Length > 0)
information = information.Substring(0, information.Length - 1);
}
else if (previous.GetPressedKeys()[i].CompareTo(Keys.A) >= 0 && previous.GetPressedKeys()[i].CompareTo(Keys.Z) <= 0)
{
information += previous.GetPressedKeys()[i];
}
else if ((previous.GetPressedKeys()[i].CompareTo(Keys.D9) <= 0 && previous.GetPressedKeys()[i].CompareTo(Keys.D0) >= 0))
{
String parseD = (previous.GetPressedKeys()[i] + "");
information += parseD.Substring(1, parseD.Length - 1); ;
}
}
}
}
}