本文整理汇总了C#中SFML.Window.KeyEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# KeyEventArgs类的具体用法?C# KeyEventArgs怎么用?C# KeyEventArgs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyEventArgs类属于SFML.Window命名空间,在下文中一共展示了KeyEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KeyPressed
public void KeyPressed(KeyEventArgs e)
{
if(ActiveWindow != null)
ActiveWindow.KeyPressed(e);
else
CurrentState.KeyPressed(e);
}
示例2: OnKeyPressed
void OnKeyPressed(object sender, KeyEventArgs e)
{
var window = (Window)sender;
if (e.Code == Keyboard.Key.Escape) window.Close();
if (e.Code == Keyboard.Key.Num1)
{
Text.DisplayedString = "1: small white square";
Render = RenderWorking;
}
if (e.Code == Keyboard.Key.Num2)
{
Text.DisplayedString = "2: RenderTexture used as background";
Render = RenderBuggy;
}
if (e.Code == Keyboard.Key.Num3)
{
Text.DisplayedString = "3: More exaggerated example of #2";
Render = RenderMoreBuggy;
}
if (e.Code == Keyboard.Key.Space)
{
DisplayText = !DisplayText;
}
}
示例3: WindowOnKeyReleased
private void WindowOnKeyReleased(object sender, KeyEventArgs keyEventArgs)
{
if (keyEventArgs.Code == Keyboard.Key.Escape)
{
Game.Instance.StateMachine.PushState(new GameStateMenu());
}
}
示例4: KeyPress
public override void KeyPress(KeyEventArgs keyEvent)
{
if(keyEvent.Code == Keyboard.Key.Return)
{
client.MyLobby.SetReady(true);
}
}
示例5: OnKeyReleased
private void OnKeyReleased(Object sender, KeyEventArgs e = null)
{
if (e != null && Game.KeyIsNotAllowed(e.Code))
return;
Parent.RemoveChild(this);
Game.Reset();
}
示例6: OnKeyPressed
private void OnKeyPressed(object sender, KeyEventArgs e)
{
SystemMessage curMessage;
curMessage = GameStates.Peek().HandleKeyInput((Window)sender, e); //delegate the key handling to our current state
HandleSystemMessage(curMessage);
}
示例7: HandleKeyInput
override public SystemMessage HandleKeyInput(Window window, KeyEventArgs e)
{
if (e.Code == Keyboard.Key.Escape)
{
return new PopStateMessage(this);
}
return null;
}
示例8: KeyUp
public void KeyUp(KeyEventArgs key)
{
foreach (Element ele in Elements)
{
if (ele != null)
ele.KeyUp(key);
}
OnKeyUp(key);
}
示例9: OnKeyPressed
private static void OnKeyPressed(object sender, KeyEventArgs e)
{
if (!KeysPressed.Contains(e.Code))
{
KeysPressed.Add(e.Code);
}
State.CurrentScreen.KeyPressed(sender, e);
}
示例10: Move
public static void Move(Object sender, KeyEventArgs e)
{
switch (e.Code)
{
case Keyboard.Key.W: if (!isColliding(1)) { y = y - Speed;} break;
case Keyboard.Key.S: if (!isColliding(2)) { y = y + Speed;} break;
case Keyboard.Key.A: if (!isColliding(3)) { x = x - Speed;} break;
case Keyboard.Key.D: if (!isColliding(4)) { x = x + Speed;} break;
}
}
示例11: KeyDown
public override bool KeyDown(KeyEventArgs e)
{
foreach (var curr in _tabs)
{
if (curr.Key.KeyDown(e)) return true;
if (_activeTab != null)
if (_activeTab.KeyDown(e)) return true;
}
return base.KeyDown(e);
}
示例12: KeyReleased
public override void KeyReleased(KeyEventArgs e)
{
if(e.Code == Keyboard.Key.W)
CamMove.Y = 0;
if(e.Code == Keyboard.Key.S)
CamMove.Y = 0;
if(e.Code == Keyboard.Key.A)
CamMove.X = 0;
if(e.Code == Keyboard.Key.D)
CamMove.X = 0;
}
示例13: Window_KeyPressed
private void Window_KeyPressed(object sender, KeyEventArgs e)
{
switch (e.Code)
{
case Keyboard.Key.Space:
LoadGame();
break;
case Keyboard.Key.Escape:
this.Game.Window.Close();
break;
}
}
示例14: HandleKeyPressed
public override void HandleKeyPressed(KeyEventArgs i)
{
switch (i.Code)
{
case Keyboard.Key.Escape:
Program.Window.SetView(Program.Window.DefaultView);
Program.StateManager.LeaveCurrentState();
break;
default:
break;
}
}
示例15: OnKeyPressed
public static void OnKeyPressed(object sender, KeyEventArgs e)
{
Console.WriteLine("Key pressed: " + e.Code);
switch (e.Code)
{
// Movement.
case SFML.Window.Keyboard.Key.A:
case SFML.Window.Keyboard.Key.Left:
{
// Move character left.
Character.getCharacter(0).position[0] -= 25;
break;
}
case SFML.Window.Keyboard.Key.D:
case SFML.Window.Keyboard.Key.Right:
{
// Move character right.
Character.getCharacter(0).position[0] += 25;
break;
}
case SFML.Window.Keyboard.Key.W:
case SFML.Window.Keyboard.Key.Up:
{
// Move character up / jump.
break;
}
case SFML.Window.Keyboard.Key.S:
case SFML.Window.Keyboard.Key.Down:
{
// Move character down / crouch.
break;
}
// Game function.
case SFML.Window.Keyboard.Key.Escape:
{
Drawing.window.Close();
Console.Title = "Asialaide (ended)";
break;
}
default:
break;
}
}