Example #1
0
        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 void Clear()
 {
     firstText = false;
     Name      = string.Empty;
     output    = string.Empty;
     input.KeysPressedInLastFrame.Clear();
     InputEngine.ClearState();
     Done = false;
 }
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                LeaveGame();
                Exit();

                #region starting in menu and switching to game
                //sets mouse state
                mouseState = Mouse.GetState();

                //switch for setting the scene
                switch (CurrentScreen)
                {
                case MENU:
                    //What we want to happen in the MENU screen goes in here.
                    //GO TO PLAYGAME SCREEN

                    if (playGameButton.update(new Vector2(mouseState.X, mouseState.Y)) == true && mouseState != previousMouseState && mouseState.LeftButton == ButtonState.Pressed && !firstText && !Done)
                    {
                        Name      = Output;
                        Output    = string.Empty;
                        firstText = true;
                        InputEngine.ClearState();
                        CurrentScreen = PLAYGAME;
                    }

                    if (InputEngine.IsKeyPressed(Keys.Enter) && firstText && !Done)
                    {
                        Output = string.Empty;
                        Done   = true;
                    }
                    if (InputEngine.IsKeyPressed(Keys.Back))
                    {
                        if (Output.Length > 0)
                        {
                            Output = Output.Remove(Output.Length - 1);
                        }
                    }
                    if (InputEngine.IsKeyPressed(Keys.Space))
                    {
                        Output += " ";
                    }
                    break;

                case PLAYGAME:
                    //What we want to happen when we play our GAME goes in here.
                    startGame();
                    break;
                }
            }
            // TODO: Add your update logic here

            previousMouseState = mouseState;
            #endregion
            base.Update(gameTime);
        }