示例#1
0
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime, KeyboardHelper keyboard)
        {
            bool enterPressed = keyboard.KeyPressedOnce(Keys.Enter);

            if (enterPressed && _player1Name.Text.Length > 0 && _player2Name.Text.Length > 0)
            {
                Global.Player1Name = _player1Name.Text;
                Global.Player2Name = _player2Name.Text;

                this.NextScreen();
                return;
            }


            bool switchFocus = keyboard.KeyPressedOnce(Keys.Tab) || enterPressed;

            if (switchFocus)
            {
                if (_player1Name.HasFocus)
                {
                    _player1Name.RemoveFocus();
                    _player2Name.SetFocus();
                }
                else if (_player2Name.HasFocus)
                {
                    _player2Name.RemoveFocus();
                    _player1Name.SetFocus();
                }
            }


            _player1Name.Update(gameTime, keyboard);
            _player2Name.Update(gameTime, keyboard);
        }
示例#2
0
        public void Update(Microsoft.Xna.Framework.GameTime gameTime, KeyboardHelper keyboard)
        {
            if (this.HasFocus)
            {
                var pressedKeys = keyboard.KeysPressedOnce(); //keyboardState.GetPressedKeys();

                foreach (var key in pressedKeys)
                {

                    switch (key)
                    {
                        case Keys.Back:
                            if (_theText.Length > 0)
                                _theText.Remove(_theText.Length-1, 1);
                            break;
                        
                        case Keys.Space:
                            _theText.Append(' ');
                            break;
                        
                        case Keys.LeftShift:
                        case Keys.RightShift:
                            //ignore
                            break;

                        default:
                            _theText.Append(key.ToString().ToUpper());
                            break;
                    }

                    
                }
            }
        }
示例#3
0
        public override void Update(GameTime gameTime, KeyboardHelper keyboard)
        {
            if (keyboard.KeyPressedOnce(Keys.D1))
                _p1Score++;

            if (keyboard.KeyPressedOnce(Keys.D2))
                _p2Score++;
        }
示例#4
0
 public override void Update(Microsoft.Xna.Framework.GameTime gameTime, KeyboardHelper keyboard)
 {
     if (keyboard.KeyPressedOnce(Keys.Enter))
         this.NextScreen();
 }