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


C# KeyboardState.IsKeyDown方法代码示例

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


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

示例1: IsKeyDownAndChanged

 private bool IsKeyDownAndChanged(KeyboardState keyState, Keys key)
 {
     bool keyDown = keyState.IsKeyDown(key);
     bool changed = keyDown != _oldState.IsKeyDown(key);
     return (keyDown && changed);
 }
开发者ID:jonkensta,项目名称:KnightGame,代码行数:6,代码来源:Controllers.cs

示例2: processKeyboardInput

        public void processKeyboardInput(KeyboardState state)
        {
            if (state.IsKeyDown(Key.W))
            {
                Pos += (Target * stepSize);
            }

            if (state.IsKeyDown(Key.S))
            {
                Pos -= (Target * stepSize);
            }

            if (state.IsKeyDown(Key.A))
            {
                Vector3 Left = Vector3.Cross(Target, Up);
                Left.Normalize();
                Left *= stepSize;
                Pos += Left;
            }

            if (state.IsKeyDown(Key.D))
            {
                Vector3 Right = Vector3.Cross(Up, Target);
                Right.Normalize();
                Right *= stepSize;
                Pos += Right;
            }


            /* Mouse movement code temporarily mapped to arrow keys */
            bool shouldUpdate = false;

            if (state.IsKeyDown(Key.Left))
            {
                angleH -= 0.1f;
                shouldUpdate = true;
            }
            else if (state.IsKeyDown(Key.Right))
            {
                angleH += 0.1f;
                shouldUpdate = true;
            }

            if (state.IsKeyDown(Key.Up))
            {
                if (angleV > -90.0f)
                {
                    angleV -= 0.1f;
                    shouldUpdate = true;
                }
            }
            else if (state.IsKeyDown(Key.Down))
            {
                if (angleV < 90.0f)
                {
                    angleV += 0.1f;
                    shouldUpdate = true;
                }
            }

            if (shouldUpdate)
            {
                update();
            }
        }
开发者ID:Ser0ja,项目名称:WoWFormatTest,代码行数:65,代码来源:OldCamera.cs

示例3: Move

        //Methods from IMovable
        public void Move(KeyboardState keyBoardState)
        {
            keyBoardState = Keyboard.GetState();

            this.Velocity = Vector2.Zero;

            if (keyBoardState.IsKeyDown(Keys.Up))
            {
                this.velocity.Y = -movementSpeed.Y;
            }
            if (keyBoardState.IsKeyDown(Keys.Left))
            {
                this.velocity.X = -movementSpeed.X;
            }
            if (keyBoardState.IsKeyDown(Keys.Down))
            {
                this.velocity.Y = movementSpeed.Y;
            }
            if (keyBoardState.IsKeyDown(Keys.Right))
            {
                this.velocity.X = movementSpeed.X;
            }

            this.Position += this.velocity;
        }
开发者ID:juliameleshko,项目名称:Franz-Kafka,代码行数:26,代码来源:Hero.cs

示例4: HandleInput

        private void HandleInput()
        {
            currentKeyboard = Keyboard.GetState();

            // Set culling mode
            if (currentKeyboard.IsKeyDown(Keys.F1))
            {
                if (!previousKeyboard.IsKeyDown(Keys.F1))
                {
                    cullingModeOn = !cullingModeOn;
                }
            }

            // Check for exit.
            if (currentKeyboard.IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // Fullscreen on/off toggle
            if (currentKeyboard.IsKeyDown(Keys.F11))
            {
                // If not down last update, key has just been pressed.
                if (!previousKeyboard.IsKeyDown(Keys.F11))
                {
                    fullscreenMode = !fullscreenMode;
                    SetScreenMode();
                }
            }

            // Seated on/off toggle
            if (currentKeyboard.IsKeyDown(Keys.V))
            {
                if (!previousKeyboard.IsKeyDown(Keys.V))
                {
                    chooser.SeatedMode = !chooser.SeatedMode;
                    skeletonDetected = false;
                }
            }

            // Near mode on/off toggle
            if (currentKeyboard.IsKeyDown(Keys.N))
            {
                if (!previousKeyboard.IsKeyDown(Keys.N))
                {
                    chooser.NearMode = !chooser.NearMode;
                    skeletonDetected = false;

                }
            }

            // Reset the avatar filters (also resets camera)
            if (currentKeyboard.IsKeyDown(Keys.R))
            {
                if (!previousKeyboard.IsKeyDown(Keys.R))
                {

                }
            }

            // Рисовать bounding boxes вкл/выкл
            if (currentKeyboard.IsKeyDown(Keys.B))
            {
                if (!previousKeyboard.IsKeyDown(Keys.B))
                {
                    drawBoundingBoxesOn = !drawBoundingBoxesOn;
                }
            }
        }
开发者ID:mikkamikka,项目名称:AlfaTestInterface,代码行数:69,代码来源:AvateeringXNA.cs

示例5: handleKeyboard

        protected void handleKeyboard(float dt)
        {
            keystate = Keyboard.GetState();

            /* Lateral movement */
            if (keystate.IsKeyDown(Key.W))
                position += forward * speed * dt;
            if (keystate.IsKeyDown(Key.S))
                position -= forward * speed * dt;
            if (keystate.IsKeyDown(Key.A))
                position -= right * speed * dt;
            if (keystate.IsKeyDown(Key.D))
                position += right * speed * dt;

            /* Fly up/down */
            if (keystate.IsKeyDown(Key.Space))
                position.Y += speed * dt;
            if (keystate.IsKeyDown(Key.LShift))
                position.Y -= speed * dt;

            /* Keyboard turn */
            if (keystate.IsKeyDown(Key.Left))
                yaw -= keyTurnSpeed * dt;
            if (keystate.IsKeyDown(Key.Right))
                yaw += keyTurnSpeed * dt;
            if (keystate.IsKeyDown(Key.Up))
                pitch += keyTurnSpeed * dt;
            if (keystate.IsKeyDown(Key.Down))
                pitch -= keyTurnSpeed * dt;
        }
开发者ID:johanhenriksson,项目名称:univ,代码行数:30,代码来源:Camera.cs


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