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


C# InputHelper.IsKeyDown方法代码示例

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


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

示例1: HandleInput

        public override void HandleInput(InputHelper inputHelper)
        {
            base.HandleInput(inputHelper);

            if (obj == null)
            {
                Vector3 vectorToAdd = Vector3.Zero;

                if (inputHelper.IsKeyDown(Keys.W))
                    vectorToAdd -= Vector3.UnitZ;
                if (inputHelper.IsKeyDown(Keys.S))
                    vectorToAdd += Vector3.UnitZ;
                if (inputHelper.IsKeyDown(Keys.D))
                    vectorToAdd += Vector3.UnitX;
                if (inputHelper.IsKeyDown(Keys.A))
                    vectorToAdd -= Vector3.UnitX;
                if (inputHelper.IsKeyDown(Keys.Q))
                    vectorToAdd -= Vector3.UnitY;
                if (inputHelper.IsKeyDown(Keys.E))
                    vectorToAdd += Vector3.UnitY;
                if (inputHelper.IsKeyDown(Keys.R))
                    position = Vector3.Zero;
                if (inputHelper.IsKeyDown(Keys.D1))
                    walkSpeed /= 1.25f;
                if (inputHelper.IsKeyDown(Keys.D2))
                    walkSpeed *= 1.25f;

                inputHelper.AddMouseRotation(rotSpeed, ref rotation);
                Matrix cameraRotation = Matrix.CreateRotationX(rotation.X) * Matrix.CreateRotationY(rotation.Y);
                Vector3 rotatedVector = Vector3.Transform(vectorToAdd * walkSpeed, cameraRotation);
                position += rotatedVector;
            }
        }
开发者ID:Dutchman97,项目名称:Game1,代码行数:33,代码来源:CameraObject.cs

示例2: HandleInput

 public override void HandleInput(InputHelper inputHelper)
 {
     if (inputHelper.IsKeyDown(Keys.Escape))
         escDown = true;
     else
         escDown = false;
 }
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:7,代码来源:CreditState.cs

示例3: HandleInput

 /// <summary>
 /// HandleInput for the level
 /// </summary>
 /// <param name="inputHelper">The inputhelper to react to input</param>
 public void HandleInput(InputHelper inputHelper)
 {
     if (inputHelper.IsKeyDown(Keys.Escape))
     {
         foreach (Sound sound in MusicPlayer.SoundEffect)
             if (sound.Name == "paperrustle")
                 sound.PlaySound();
         GameEnvironment.GameStateManager.SwitchTo("pauseScreenState");
     }
     level.HandleInput(inputHelper);
 }
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:15,代码来源:PlayingState.cs

示例4: HandleInput

 /// <summary>Handle user input.</summary>
 public override void HandleInput(InputHelper inputHelper)
 {
     float walkingSpeed = 400;
     if (walkingOnIce)
         walkingSpeed *= 1.5f;
     if (!isAlive)
         return;
     if (inputHelper.IsKeyDown(Keys.Left) || inputHelper.IsKeyDown(Keys.A) || inputHelper.IsControlerButtonDown(Buttons.DPadLeft) || inputHelper.GetLeftControlerStick() == Direction.Left)
         velocity.X = -walkingSpeed;
     else if (inputHelper.IsKeyDown(Keys.Right) || inputHelper.IsKeyDown(Keys.D) || inputHelper.IsControlerButtonDown(Buttons.DPadRight) || inputHelper.GetLeftControlerStick() == Direction.Right)
         velocity.X = walkingSpeed;
     else if (!walkingOnIce && isOnTheGround)
         velocity.X = 0.0f;
     if (velocity.X != 0.0f)
         Mirror = velocity.X < 0;
     if ((inputHelper.KeyPressed(Keys.Up) || inputHelper.KeyPressed(Keys.W) || inputHelper.ControlerButtonPressed(Buttons.DPadUp) || inputHelper.ControlerButtonPressed(Buttons.A)) && isOnTheGround)
         Jump();
     if (inputHelper.KeyPressed(Keys.Space) || inputHelper.ControlerButtonPressed(Buttons.X))
         Shoot();
 }
开发者ID:alikimoko,项目名称:Practicum3.Platformer,代码行数:21,代码来源:Player.cs

示例5: HandleInput

    /// <summary>
    /// HandleInput for the player
    /// </summary>
    /// <param name="inputHelper">The inputhelper to react to input</param>
    public override void HandleInput(InputHelper inputHelper)
    {
        ShiftDown = false;
        WDown = false;
        ADown = false;
        SDown = false;
        DDown = false;
        EDown = false;

        if (inputHelper.IsKeyDown(Keys.LeftShift))
            ShiftDown = true;
        if (inputHelper.IsKeyDown(Keys.W))
            WDown = true;
        if (inputHelper.IsKeyDown(Keys.A))
            ADown = true;
        if (inputHelper.IsKeyDown(Keys.S))
            SDown = true;
        if (inputHelper.IsKeyDown(Keys.D))
            DDown = true;
        if (inputHelper.IsKeyDown(Keys.E))
            EDown = true;

        if (((WDown || ADown || SDown || DDown) && !ShiftDown) || (WDown || ADown || SDown || DDown) && ShiftDown && exhausted)
        {
            foreach (Sound sound in MusicPlayer.LoopedEffect)
                if (sound.Name == "Footsteps1")
                {
                    sound.PlaySound(0.5f);
                }
        }
        else
        {
            foreach (Sound sound in MusicPlayer.LoopedEffect)
                if (sound.Name == "Footsteps1")
                    sound.StopSound();
        }

        if ((WDown || ADown || SDown || DDown) && ShiftDown && !exhausted)
        {
            foreach (Sound sound in MusicPlayer.LoopedEffect)
                if (sound.Name == "Footsteps2")
                {
                    sound.PlaySound(0.5f);
                }
        }
        else
        {
            foreach (Sound sound in MusicPlayer.LoopedEffect)
                if (sound.Name == "Footsteps2")
                    sound.StopSound();
        }
        base.HandleInput(inputHelper);
    }
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:57,代码来源:Player.cs

示例6: HandleInput

 public override void HandleInput(InputHelper inputHelper)
 {
     float walkingSpeed = 400;
     if (walkingOnIce)
         walkingSpeed *= 1.5f;
     if (!isAlive)
         return;
     if (inputHelper.IsKeyDown(Keys.Left))
         velocity.X = -walkingSpeed;
     else if (inputHelper.IsKeyDown(Keys.Right))
         velocity.X = walkingSpeed;
     else if (!walkingOnIce && isOnTheGround)
         velocity.X = 0.0f;
     if (velocity.X != 0.0f)
         Mirror = velocity.X < 0;
     if ((inputHelper.KeyPressed(Keys.Up)) && isOnTheGround)
         Jump();
 }
开发者ID:FranssZ,项目名称:TickTick_Roel_Frans,代码行数:18,代码来源:Player.cs

示例7: HandleInput

 public override void HandleInput(InputHelper inputHelper)
 {
     checkMaxRange();
     if (vertical)
     {
         if (inputHelper.IsKeyDown(key1))
         {
             velocity.Y = -newVelocity;
         }
         else if (inputHelper.IsKeyDown(key2))
         {
             velocity.Y = newVelocity;
         }
         else
         {
             velocity.Y = 0;
         }
     }
     else
     {
         if(inputHelper.IsKeyDown(key1))
         {
             velocity.X = -newVelocity;
         }
         else if (inputHelper.IsKeyDown(key2))
         {
             velocity.X = newVelocity;
         }
         else
         {
             velocity.X = 0;
         }
     }
 }
开发者ID:Chartle,项目名称:Gameprogrammeren-Practica,代码行数:34,代码来源:Paddle.cs

示例8: HandleInput

 public override void HandleInput(InputHelper inputHelper)
 {
     walkingSpeed = 400;
     //Als hij over een ijsblokje heen loopt, gaat hij steeds sneller
     if (walkingOnIce)
         walkingSpeed *= 1.5f;
     if (!isAlive)
         return;
     //Hij beweegt naar links
     if (inputHelper.IsKeyDown(Keys.A))
     {
         velocity.X = -walkingSpeed;
         walking = true;
     }
     //Hij beweegt naar rechts
     else if (inputHelper.IsKeyDown(Keys.D))
     {
         velocity.X = walkingSpeed;
         walking = true;
     }
     //Als hij niet op ijs staat, kan hij stilstaan
     else if (!walkingOnIce && isOnTheGround)
     {
         walking = false;
         velocity.X = 0.0f;
     }
     if (velocity.X != 0.0f)
         Mirror = velocity.X < 0;
     //Hij springt als hij op de grond staat en er op spatie wordt gedrukt
     if ((inputHelper.KeyPressed(Keys.Space) || inputHelper.KeyPressed(Keys.W)) && isOnTheGround)
         Jump();
     Parallax();
 }
开发者ID:TheHappyCow,项目名称:TickTick,代码行数:33,代码来源:Player.cs

示例9: HandleInput

        public void HandleInput(GameTime gameTime, InputHelper inputHelper)
        {
            if (inputHelper.KeyPressed(Keys.Left, false))
            {
                if (canMove((int)blockPosition.X-1, (int)blockPosition.Y, false))
                {
                    blockPosition.X--;
                }

            }
            if (inputHelper.KeyPressed(Keys.Right, false))
            {
                if (canMove((int)blockPosition.X + 1, (int)blockPosition.Y, false))
                {
                    blockPosition.X++;
                }

            }
            if (inputHelper.KeyPressed(Keys.Up, false))
            {
                if (canRotate())
                {
                    activeBlock.RotateCW();
                    putBlockInGrid();
                }
            }

            if (inputHelper.KeyPressed(Keys.NumPad1, false))
            {
                nextBlock = new TallBlock(gridBlockTex);
            }

            if (inputHelper.KeyPressed(Keys.NumPad2, false))
            {
                nextBlock = new JBlock(gridBlockTex);
            }

            if (inputHelper.KeyPressed(Keys.NumPad3, false))
            {
                nextBlock = new LBlock(gridBlockTex);
            }

            if (inputHelper.KeyPressed(Keys.NumPad4, false))
            {
                nextBlock = new TBlock(gridBlockTex);
            }

            if (inputHelper.KeyPressed(Keys.NumPad5, false))
            {
                nextBlock = new SBlock(gridBlockTex);
            }

            if (inputHelper.KeyPressed(Keys.NumPad6, false))
            {
                nextBlock = new ZBlock(gridBlockTex);
            }

            if (inputHelper.KeyPressed(Keys.NumPad8, false))
            {
                nextBlock = new SquareBlock(gridBlockTex);
            }

            if (inputHelper.IsKeyDown(Keys.Down))
            {
                if (timeToMove >= 0.10d)
                timeToMove = 0.10d;
            }
            else
            {
                if (blockCount < 10)
                {
                    timeToMove = 0.25d;
                }
                else
                {
                    timeToMove = 0.25d - (blockCount / 10) * 0.035;
                }
            }
        }
开发者ID:Gmans,项目名称:Game_Programmeren,代码行数:79,代码来源:TetrisGrid.cs

示例10: HandleInput

        public override void HandleInput(InputHelper inputHelper)
        {
            base.HandleInput(inputHelper);

            if (Target == null)
                return;

            switch (Mode)
            {
                case MovementMode.XYZ:
                    #region XYZ
                    Vector3 vectorToAdd = Vector3.Zero;

                    if (inputHelper.IsKeyDown(Keys.W))
                        vectorToAdd -= Vector3.UnitZ;
                    if (inputHelper.IsKeyDown(Keys.S))
                        vectorToAdd += Vector3.UnitZ;
                    if (inputHelper.IsKeyDown(Keys.D))
                        vectorToAdd += Vector3.UnitX;
                    if (inputHelper.IsKeyDown(Keys.A))
                        vectorToAdd -= Vector3.UnitX;
                    if (inputHelper.IsKeyDown(Keys.Q))
                        vectorToAdd -= Vector3.UnitY;
                    if (inputHelper.IsKeyDown(Keys.E))
                        vectorToAdd += Vector3.UnitY;
                    if (inputHelper.IsKeyDown(Keys.R))
                        position = Vector3.Zero;
                    if (inputHelper.IsKeyDown(Keys.D1))
                        Speed /= 1.25f;
                    if (inputHelper.IsKeyDown(Keys.D2))
                        Speed *= 1.25f;

                    inputHelper.AddMouseRotation(RotationSpeed * updateTime, ref rotation);
                    Matrix cameraRotation = Matrix.CreateRotationX(rotation.X) * Matrix.CreateRotationY(rotation.Y);
                    Vector3 rotatedVector = Vector3.Transform(vectorToAdd * Speed * updateTime, cameraRotation);
                    position += rotatedVector;
                    #endregion XYZ
                    break;
                case MovementMode.XZ:
                    break;
                default:
                    break;
            }
        }
开发者ID:Dutchman97,项目名称:Game1,代码行数:44,代码来源:MovementHandler.cs


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