public override void Update(GameTime gameTime) { keyboard.Update(gameTime); if (InputEngine.IsKeyPressed(Keys.Enter) && !firstText && !Done) { Name = Output; Output = string.Empty; firstText = true; keyboard.Output = string.Empty; InputEngine.ClearState(); } if (InputEngine.IsKeyPressed(Keys.Enter) && firstText && !Done) { Output = string.Empty; keyboard.Output = string.Empty; Done = true; Enabled = false; Visible = false; } if (InputEngine.IsKeyPressed(Keys.Back)) { if (Output.Length > 0) { Output = Output.Remove(Output.Length - 1); } } if (InputEngine.IsKeyPressed(Keys.Space)) { Output += " "; } base.Update(gameTime); }
public GetGameInputComponent(Game g) : base(g) { g.Components.Add(this); IsMouseVisible = true; input = new InputEngine(g); keyboard = new SimpleKeyboard(new Vector2(10, 10)); }
public void Update(GameTime gametime) { foreach (var key in keys) { var rect = new Rectangle((int)key.Position.X, (int)key.Position.Y, key.Width, key.Height); if (rect.Contains((int)InputEngine.MousePosition.X, (int)InputEngine.MousePosition.Y)) { key.IsMouseOver = true; if (InputEngine.IsMouseLeftClick()) { if (key.Text == "Space") { Output += " "; } else if (key.Text == "Delete") { if (Output.Length > 0) { Output = Output.Remove(Output.Length - 1); } } else { Output += key.Text; } } } else { key.IsMouseOver = false; } } }
public void Clear() { firstText = false; Name = string.Empty; output = string.Empty; input.KeysPressedInLastFrame.Clear(); keyboard.Output = string.Empty; InputEngine.ClearState(); Done = false; }