当前位置: 首页>>代码示例>>C#>>正文


C# KeyboardState.IsKeyUp方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Input.KeyboardState.IsKeyUp方法的典型用法代码示例。如果您正苦于以下问题:C# KeyboardState.IsKeyUp方法的具体用法?C# KeyboardState.IsKeyUp怎么用?C# KeyboardState.IsKeyUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Input.KeyboardState的用法示例。


在下文中一共展示了KeyboardState.IsKeyUp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleInput

        private bool jump; //True if able to jump

        #endregion Fields

        #region Methods

        public void HandleInput(KeyboardState keys)
        {
            if (keys.IsKeyDown(Keys.Right))
            {
                xAcl = 5;
                xDcl = 0;
            }
            if (keys.IsKeyDown(Keys.Left))
            {
                xAcl = -5;
                xDcl = 0;
            }
            if (keys.IsKeyDown(Keys.Down))
            {
                posY += 5;
            }
            if (keys.IsKeyDown(Keys.Up))
            {
                posY -= 5;
            }
            if (keys.IsKeyUp(Keys.Right) && (!keys.IsKeyDown(Keys.Left)))
                xAcl = 0;
            if (keys.IsKeyUp(Keys.Left) && (!keys.IsKeyDown(Keys.Right)))
                xAcl = 0;
        }
开发者ID:Tobaz,项目名称:platformancy,代码行数:31,代码来源:Player.cs

示例2: Update

        public void Update(KeyboardState clavier, Menu menu)
        {
            if (clavier.IsKeyDown(Keys.Escape))
                pauseactive = true;

            if (clavier.IsKeyUp(Keys.Escape) && pauseactive)
            {
                if (Etat == etat.InGame)
                {
                    Etat = etat.Pause;
                    menu.mode = Menu.Mode.Pause;
                }

                pauseactive = false;
            }

            if (clavier.IsKeyDown(Keys.Space))
                combatactive = true;

            if (clavier.IsKeyUp(Keys.Space) && combatactive)
            {
                if (Etat == etat.InGame)
                {
                    combat = !combat;
                }

                combatactive = false;
            }
        }
开发者ID:Darkrely,项目名称:1ere-soutenance,代码行数:29,代码来源:GameManager.cs

示例3: Update

        public void Update(GameTime gameTime, Vector2 mapSize)
        {
            lastKeyboardState = keyboardState;
            keyboardState = Keyboard.GetState();

            position = new Vector2((int)deplacement.X * 16, (int)deplacement.Y * 16);

            //choisis la texture
            if (keyboardState.IsKeyDown(Keys.F5) && lastKeyboardState.IsKeyUp(Keys.F5))
                Texture = ressource.ARBRE;

            else if (keyboardState.IsKeyDown(Keys.F6) && lastKeyboardState.IsKeyUp(Keys.F6))
                Texture = ressource.SOL;

            else if (keyboardState.IsKeyDown(Keys.F7) && lastKeyboardState.IsKeyUp(Keys.F7))
                Texture = ressource.STATUT;

            //deplace le curseur
            if (keyboardState.IsKeyDown(Keys.J) && lastKeyboardState.IsKeyUp(Keys.J) && position.X > 0)
                deplacement.X--;

            if (keyboardState.IsKeyDown(Keys.L) && lastKeyboardState.IsKeyUp(Keys.L) && position.X < mapSize.X - 1)
                deplacement.X++;

            if (keyboardState.IsKeyDown(Keys.I) && lastKeyboardState.IsKeyUp(Keys.I) && position.Y > 0)
                deplacement.Y--;

            if (keyboardState.IsKeyDown(Keys.K) && lastKeyboardState.IsKeyUp(Keys.K) && position.Y < mapSize.Y - 1)
                deplacement.Y++;
        }
开发者ID:tchiiikun,项目名称:Templar,代码行数:30,代码来源:Cursor.cs

示例4: Update

 public override void Update(GameTime gameTime)
 {
     base.Update(gameTime);
     MouseState mouseState = Mouse.GetState();
     deltaMousePos = new Point(mouseState.X - mousePosition.X, mouseState.Y - mousePosition.Y);
     mousePosition.X = mouseState.X;
     mousePosition.Y = mouseState.Y;
     deltaScroll = mouseState.ScrollWheelValue - mouseScrollValue;
     mouseScrollValue = mouseState.ScrollWheelValue;
     leftMouseDown = mouseState.LeftButton == ButtonState.Pressed;
     rightMouseDown = mouseState.RightButton == ButtonState.Pressed;
     prevState = curState;
     curState = Keyboard.GetState();
     int posX = (curState.IsKeyDown(Keys.D) || curState.IsKeyDown(Keys.Right)) ? 1 : 0;
     int negX = (curState.IsKeyDown(Keys.A) || curState.IsKeyDown(Keys.Left)) ? -1 : 0;
     int posY = (curState.IsKeyDown(Keys.W) || curState.IsKeyDown(Keys.Up)) ? 1 : 0;
     int negY = (curState.IsKeyDown(Keys.S) || curState.IsKeyDown(Keys.Down)) ? -1 : 0;
     movementDir = new Vector2(posX + negX, posY + negY);
     if (movementDir != Vector2.Zero)
         movementDir.Normalize();
     spaceBarPressed = curState.IsKeyDown(Keys.Space) && prevState.IsKeyUp(Keys.Space);
     shiftDown = curState.IsKeyDown(Keys.LeftShift) || curState.IsKeyDown(Keys.RightShift);
     shiftUp = curState.IsKeyUp(Keys.LeftShift) && curState.IsKeyUp(Keys.RightShift);
     enterDown = curState.IsKeyDown(Keys.Enter);
     escapeDown = curState.IsKeyDown(Keys.Escape);
 }
开发者ID:JuzzWuzz,项目名称:TheSaver,代码行数:26,代码来源:Input.cs

示例5: Update

        public void Update(KeyboardState clavier, Menu menu)
        {
            #region GestionPause
            if (clavier.IsKeyDown(Keys.Escape))
                pauseactive = true;

            if (clavier.IsKeyUp(Keys.Escape) && pauseactive)
            {
                if (Etat == etat.InGame)
                {
                    menu.mode = Menu.Mode.Pause;
                    Etat = etat.Pause;
                }

                pauseactive = false;
            }
            #endregion

            #region Gestion Combat
            if (clavier.IsKeyDown(Keys.Space))
                combatactive = true;

            if (clavier.IsKeyUp(Keys.Space) && combatactive)
            {
                if (Etat == etat.InGame)
                {
                    combat = !combat;
                }

                combatactive = false;
            }
            #endregion
        }
开发者ID:Darkrely,项目名称:Seconde_soutenance,代码行数:33,代码来源:GameManager.cs

示例6: HandleInput

        public static void HandleInput(GameTime gameTime, PlayableCharacter unit)
        {
            previousKeyboardState = currentKeyboardState;
            currentKeyboardState = Keyboard.GetState();

            //if (currentKeyboardState.GetPressedKeys().Length == 0)
            //{
            //    // Idle
            //}

            //Reset any currently ongoing animation
            if (currentKeyboardState.IsKeyDown(Keys.R) && previousKeyboardState.IsKeyUp(Keys.R))
            {
                unit.ResetAnimation();
            }

            if (currentKeyboardState != previousKeyboardState)
            {
                if (!unit.IsAttackingRanged)
                {
                    //unit.ResetAnimationCounter();
                }
                unit.MakeUnitIdle();
            }

            // Move Right
            if (currentKeyboardState.IsKeyDown(Keys.Right))
            {
                unit.ValidateMovementRight();
            }

            // Move Left
            if (currentKeyboardState.IsKeyDown(Keys.Left))
            {
                unit.ValidateMovementLeft();
            }

            // Jumping
            if (currentKeyboardState.IsKeyDown(Keys.Up)
                && previousKeyboardState.IsKeyUp(Keys.Up))
            {
                unit.ValidateJump();
            }

            // RangedAttack

            if (currentKeyboardState.IsKeyDown(Keys.A)
                && currentKeyboardState.IsKeyDown(Keys.S)
                && previousKeyboardState.IsKeyUp(Keys.S))
            {
                unit.ComboStageCounter += 2;
                unit.ValidateRangedAttack();
            }
            else if (currentKeyboardState.IsKeyDown(Keys.A)
               && previousKeyboardState.IsKeyUp(Keys.A))
            {
                unit.ValidateRangedAttack();
            }
        }
开发者ID:CharlieScarver,项目名称:TeamMidori,代码行数:59,代码来源:InputHandler.cs

示例7: Update

 public override void Update(GameTime gameTime, GamePadState newGamePadState, GamePadState oldGamePadState, KeyboardState newKeyboardState, KeyboardState oldKeyboardState)
 {
     if ((newGamePadState.Buttons.B != oldGamePadState.Buttons.B && newGamePadState.Buttons.B == ButtonState.Pressed)
         || (newKeyboardState.IsKeyDown(Keys.Enter) && oldKeyboardState.IsKeyUp(Keys.Enter))
         || (newKeyboardState.IsKeyDown(Keys.B) && oldKeyboardState.IsKeyUp(Keys.B))) {
         Game.GameStartingScreen = GameStartingScreen.SetupScreen;
     }
 }
开发者ID:bstockus,项目名称:WarehouseZombieAttack,代码行数:8,代码来源:InstructionsScreen.cs

示例8: InputKeyBoard_KeyEvent

        void InputKeyBoard_KeyEvent(KeyboardState keyNewState, KeyboardState keyOldState)
        {
            if (keyNewState.IsKeyDown(Keys.Escape) && keyOldState.IsKeyUp(Keys.Escape)) game.Exit();

            if (keyNewState.IsKeyDown(Keys.Up) && keyOldState.IsKeyUp(Keys.Up)) game.Window.Title = "Up";
            if (keyNewState.IsKeyDown(Keys.Down) && keyOldState.IsKeyUp(Keys.Down)) game.Window.Title = "Down";
            if (keyNewState.IsKeyDown(Keys.Left) && keyOldState.IsKeyUp(Keys.Left)) game.Window.Title = "Left";
            if (keyNewState.IsKeyDown(Keys.Right) && keyOldState.IsKeyUp(Keys.Right)) game.Window.Title = "Right";
        }
开发者ID:bharathi355,项目名称:davethegame,代码行数:9,代码来源:InputTest.cs

示例9: Update

        public void Update(GameTime gameTime)
        {
            guiSystem.Update();
            CurrentKeyboardState = Keyboard.GetState();
            if ((CurrentKeyboardState.IsKeyUp(Keys.Enter) && PreviousKeyboardState.IsKeyDown(Keys.Enter)) || (CurrentKeyboardState.IsKeyUp(Keys.E) && PreviousKeyboardState.IsKeyDown(Keys.E)))
            {
                if (btnControlUp.IsSelected)

                if (btnReturn.IsSelected)
                    Game1.gameState = Game1.GameState.StartMenu;
            }
            PreviousKeyboardState = Keyboard.GetState();
        }
开发者ID:Spikky577,项目名称:Levi-Challenge,代码行数:13,代码来源:OptionsMenuScreen.cs

示例10: Update

        public void Update(GameTime gameTime)
        {
            keyState = Keyboard.GetState();

            if (keyState.IsKeyUp(Keys.D1) == true && oldKeyState.IsKeyDown(Keys.D1) == true)
            {
                one = true;
            }
            else
            {
                one = false;
            }

            if (keyState.IsKeyUp(Keys.D2) == true && oldKeyState.IsKeyDown(Keys.D2) == true)
            {
                two = true;
            }
            else
            {
                two = false;
            }

            if (keyState.IsKeyUp(Keys.D3) == true && oldKeyState.IsKeyDown(Keys.D3) == true)
            {
                three = true;
            }
            else
            {
                three = false;
            }

            if (keyState.IsKeyUp(Keys.D4) == true && oldKeyState.IsKeyDown(Keys.D4) == true)
            {
                four = true;
            }
            else
            {
                four = false;
            }

            if (keyState.IsKeyUp(Keys.D5) == true && oldKeyState.IsKeyDown(Keys.D5) == true)
            {
                five = true;
            }
            else
            {
                five = false;
            }

            oldKeyState = keyState;
        }
开发者ID:rodstrom,项目名称:soul,代码行数:51,代码来源:SpawnEnemies.cs

示例11: Update

        public void Update(float elapsed, KeyboardState currentKey, KeyboardState oldKey, MouseState currentMouse, MouseState oldMouse) {
            totalElapsed += elapsed;
            if (animated) {
                if (totalElapsed > animationSpeed) {
                    currentFrame++;
                    if (currentFrame == totalFrames - 2)
                        currentFrame = 0;
                    totalElapsed = 0;
                }
            }
            Vector2 direction = new Vector2(Mouse.GetState().X, Mouse.GetState().Y - World.HUD) - Position;
            if (direction != Vector2.Zero)
                direction.Normalize();
            Rotation = (float)Math.Atan2(direction.Y, direction.X);

            Weapon.Update(elapsed);
            if (currentMouse.LeftButton == ButtonState.Pressed && oldMouse.LeftButton == ButtonState.Released) {
                Weapon.Execute(new Vector2((float)Math.Cos(Rotation), (float)Math.Sin(Rotation)), Position);
            }
            if (invTmr > 0) {
                invTmr -= elapsed / 1000;
            }

            #region CurrentMovement
            //Can be changed
            if (currentKey.IsKeyDown(Keys.W))
                Velocity = new Vector2((float)Math.Cos(Rotation), (float)Math.Sin(Rotation));
            if (currentKey.IsKeyDown(Keys.S))
                Velocity = new Vector2((float)Math.Cos(Rotation + MathHelper.ToRadians(180)), (float)Math.Sin(Rotation + MathHelper.ToRadians(180)));
            if (currentKey.IsKeyDown(Keys.D))
                Velocity = new Vector2((float)Math.Cos(Rotation + MathHelper.ToRadians(90)), (float)Math.Sin(Rotation + MathHelper.ToRadians(90)));
            if (currentKey.IsKeyDown(Keys.A))
                Velocity = new Vector2((float)Math.Cos(Rotation + MathHelper.ToRadians(-90)), (float)Math.Sin(Rotation + MathHelper.ToRadians(-90)));


            if (currentKey.IsKeyDown(Keys.W) && currentKey.IsKeyDown(Keys.D))
                Velocity = new Vector2((float)Math.Cos(Rotation + MathHelper.ToRadians(45)), (float)Math.Sin(Rotation + MathHelper.ToRadians(45)));
            if (currentKey.IsKeyDown(Keys.W) && currentKey.IsKeyDown(Keys.A))
                Velocity = new Vector2((float)Math.Cos(Rotation + MathHelper.ToRadians(-45)), (float)Math.Sin(Rotation + MathHelper.ToRadians(-45)));
            if (currentKey.IsKeyDown(Keys.S) && currentKey.IsKeyDown(Keys.D))
                Velocity = new Vector2((float)Math.Cos(Rotation + MathHelper.ToRadians(135)), (float)Math.Sin(Rotation + MathHelper.ToRadians(135)));
            if (currentKey.IsKeyDown(Keys.S) && currentKey.IsKeyDown(Keys.A))
                Velocity = new Vector2((float)Math.Cos(Rotation + MathHelper.ToRadians(-135)), (float)Math.Sin(Rotation + MathHelper.ToRadians(-135)));

            if (currentKey.IsKeyUp(Keys.W) && currentKey.IsKeyUp(Keys.A) && currentKey.IsKeyUp(Keys.S) && currentKey.IsKeyUp(Keys.D)) {
                Velocity = Vector2.Zero;
                currentFrame = totalFrames - 1;
            }
            else if (currentFrame == totalFrames - 1)
                currentFrame = 0;
            animationSpeed = currentKey.IsKeyUp(Keys.W) && currentKey.IsKeyUp(Keys.A) && currentKey.IsKeyUp(Keys.S) && currentKey.IsKeyUp(Keys.D)
                ? int.MaxValue : storedAnimationSpeed;

            if (Velocity != null)
                Velocity.Normalize();

            OldPos = Position;
            Position += Velocity * speed;
            #endregion
        }
开发者ID:CyberSpiral,项目名称:Guitar-Hero,代码行数:60,代码来源:Player.cs

示例12: Update

        public static void Update(GameTime gameTime, KeyboardState state, KeyboardState prevState)
        {
            if (!GameScene.player.projectileLaunched) {
                if (spells ["fireball"] && state.IsKeyDown (Keys.H) && prevState.IsKeyUp (Keys.H) && GameScene.player.HasEnoughMana (2)) {
                    GameScene.player.Fireball ();
                } else if (spells ["frostbreath"] && state.IsKeyDown (Keys.J) && prevState.IsKeyUp (Keys.J) && GameScene.player.HasEnoughMana (1)) {
                    GameScene.player.FrostBreath ();
                }
            }

            if (spells ["earthen shield"]) {
                if (state.IsKeyDown (Keys.K) && prevState.IsKeyUp (Keys.K)) {
                    if (activeSpell == "") {
                        GameScene.player.EarthenStrength ();
                    } else {
                        GameScene.player.DestroyOverlay ();
                        if (activeSpell != "earthen shield") {
                            if (GameScene.player.HasEnoughMana (1)) {
                                GameScene.player.EarthenStrength ();
                            }
                        } else {
                            activeSpell = "";
                        }
                    }
                }
            }
            if (spells ["windwalk"]) {
                if (state.IsKeyDown (Keys.L) && prevState.IsKeyUp (Keys.L)) {
                    if (activeSpell == "") {
                        GameScene.player.WindWalk ();
                    } else {
                        GameScene.player.DestroyOverlay ();
                        if (activeSpell != "windwalk") {
                            if (GameScene.player.HasEnoughMana (1)) {
                                GameScene.player.WindWalk ();
                            }
                        } else {
                            activeSpell = "";
                        }
                    }
                }
            }
            if (activeSpell != "") {
                drainTimer -= gameTime.ElapsedGameTime;
                if (drainTimer.Milliseconds <= 0) {
                    DrainMana ();
                }
            }
        }
开发者ID:jgeumlek,项目名称:Element-Chronicles-Prototype,代码行数:49,代码来源:SpellManager.cs

示例13: Keyboard

	    public override void Keyboard(KeyboardState state, KeyboardState oldState)
	    {
            if (state.IsKeyDown(Keys.L) && oldState.IsKeyUp(Keys.L))
            {
                _joint.EnableLimit(!_joint.IsLimitEnabled());
            }
            if (state.IsKeyDown(Keys.M) && oldState.IsKeyUp(Keys.M))
            {
                _joint.EnableMotor(!_joint.IsMotorEnabled());
            }
            if (state.IsKeyDown(Keys.P) && oldState.IsKeyUp(Keys.P))
            {
                _joint.SetMotorSpeed(-_joint.GetMotorSpeed());
            }
	    }
开发者ID:n1ckd0r,项目名称:Box2D.XNA,代码行数:15,代码来源:Prismatic.cs

示例14: Update

        public virtual void Update(GameTime gameTime, EventManager events)
        {
            // Keyboard
              lastKeyboard = keyboard;
              keyboard = Keyboard.GetState();

              bool pressUp = keyboard.IsKeyUp(Keys.Up) && lastKeyboard.IsKeyDown(Keys.Up);
              bool pressDown = keyboard.IsKeyUp(Keys.Down) && lastKeyboard.IsKeyDown(Keys.Down);
              bool pressLeft = keyboard.IsKeyUp(Keys.Left) && lastKeyboard.IsKeyDown(Keys.Left);
              bool pressRight = keyboard.IsKeyUp(Keys.Right) && lastKeyboard.IsKeyDown(Keys.Right);

              bool downUp = keyboard.IsKeyDown(Keys.Up);
              bool downDown = keyboard.IsKeyDown(Keys.Down);
              bool downLeft = keyboard.IsKeyDown(Keys.Left);
              bool downRight = keyboard.IsKeyDown(Keys.Right);

              bool keyT = keyboard.IsKeyUp(Keys.T) && lastKeyboard.IsKeyDown(Keys.T);
              //bool keyN = keyboard.IsKeyUp(Keys.N) && lastKeyboard.IsKeyDown(Keys.N);

              // Key Press Events
              if (pressUp)
            events.Notify(Event.PressUP, null);

              if (pressDown)
            events.Notify(Event.PressDOWN, null);

              if (pressLeft)
            events.Notify(Event.PressLEFT, null);

              if (pressRight)
            events.Notify(Event.PressRIGHT, null);

              // Key Down Events
              if (downUp)
            events.Notify(Event.KeyDownUP, null);

              if (downDown)
            events.Notify(Event.KeyDownDOWN, null);

              if (downLeft)
            events.Notify(Event.KeyDownLEFT, null);

              if (downRight)
            events.Notify(Event.KeyDownRIGHT, null);

              //if (keyN)
              //  events.Notify(Event.NextScene, null);
        }
开发者ID:colincapurso,项目名称:LD25,代码行数:48,代码来源:AInput.cs

示例15: localUpdate

 public void localUpdate(KeyboardState ks)
 {
     if (ks.IsKeyDown(Keys.Up) && ks.IsKeyUp(Keys.Down))
     {
         if(position.Y > 0){
             position.Y -=5 ;
         }
     }
     else if (ks.IsKeyDown(Keys.Down) && ks.IsKeyUp(Keys.Up))
     {
         if (position.Y + 60 < 480)
         {
             position.Y += 5;
         }
     }
 }
开发者ID:Anamor7,项目名称:CommNetPong,代码行数:16,代码来源:Player.cs


注:本文中的Microsoft.Xna.Framework.Input.KeyboardState.IsKeyUp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。