• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# KeyboardState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Update

        protected override void Update(TimeSpan gameTime)
        {
            input = WaveServices.Input;

            if (input.KeyboardState.IsConnected)
            {
                keyboardState = input.KeyboardState;

                if (keyboardState.W == ButtonState.Pressed)
                {
                    MoveCamera(ref forward);
                }
                if (keyboardState.S == ButtonState.Pressed)
                {
                    MoveCamera(ref back);
                }
                if (keyboardState.A == ButtonState.Pressed)
                {
                    MoveCamera(ref left);
                }
                if (keyboardState.D == ButtonState.Pressed)
                {
                    MoveCamera(ref right);
                }
            }
            var rotationMatrix = (Matrix.CreateRotationX(MathHelper.ToRadians(45.0f)) * Matrix.CreateRotationY(MathHelper.ToRadians(30.0f)));
            Vector3 transformedReference = Vector3.Transform(Vector3.Down, rotationMatrix);
            Vector3 cameraLookat = Camera.Position + transformedReference;
            var width = WaveServices.Platform.ScreenWidth / 24;
            var height = WaveServices.Platform.ScreenHeight / 24;

            //camera.Projection = Matrix.CreateOrthographic(width, height, camera.NearPlane, camera.FarPlane);
            Camera.LookAt = cameraLookat;
        }
开发者ID:123asd123A,项目名称:Samples,代码行数:34,代码来源:IsometricCameraBehavior.cs


示例2: Keyboard

 public Keyboard()
 {
     var directInput = new DirectInput();
     mKeyboard = new SlimDX.DirectInput.Keyboard(directInput);
     mKeyboard.Acquire();
     mState = new KeyboardState();
 }
开发者ID:Christof,项目名称:ionfish,代码行数:7,代码来源:Keyboard.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: Update

        /// <summary>
        /// Update Method
        /// </summary>
        /// <param name="gameTime"></param>
        protected override void Update(TimeSpan gameTime)
        {
            this.input = WaveServices.Input;

            // if (this.input.KeyboardState.IsConnected)
            {
                this.keyboardState = this.input.KeyboardState;

                if (revoluteJoint != null)
                {
                    // A, D, S Keyboard Control (left, right, stop motor)
                    if (this.keyboardState.A == ButtonState.Pressed)
                    {
                        if (revoluteJoint.MotorSpeed + motorSpeed <= maxSpeed)
                        {
                            revoluteJoint.MotorSpeed += motorSpeed;
                        }
                    }
                    else if (this.keyboardState.D == ButtonState.Pressed)
                    {
                        if (revoluteJoint.MotorSpeed - motorSpeed >= -maxSpeed)
                        {
                            revoluteJoint.MotorSpeed -= motorSpeed;
                        }
                    }
                    else if (this.keyboardState.S == ButtonState.Pressed)
                    {
                        revoluteJoint.MotorSpeed = 0.0f;
                    }
                }
            }
        }
开发者ID:nagyistoce,项目名称:WaveEngine-Samples,代码行数:36,代码来源:MotorBehavior.cs


示例5: Update

        /// <summary>
        /// Allows this instance to execute custom logic during its <c>Update</c>.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        /// <remarks>
        /// This method will not be executed if it are not <c>Active</c>.
        /// </remarks>
        protected override void Update(TimeSpan gameTime)
        {
            inputService = WaveServices.Input;

            if (inputService.KeyboardState.IsConnected)
            {
                // Key F1
                if (inputService.KeyboardState.F1 == ButtonState.Pressed &&
                    beforeKeyboardState.F1 != ButtonState.Pressed)
                {
                    this.diagnostics = !this.diagnostics;
                    WaveServices.ScreenContextManager.SetDiagnosticsActive(this.diagnostics);
                }

                // Key F3
                if (inputService.KeyboardState.F3 == ButtonState.Pressed &&
                    beforeKeyboardState.F3 != ButtonState.Pressed)
                {
                    this.debugLines = !this.debugLines;
                    this.Scene.RenderManager.DebugLines = this.debugLines;
                }
            }

            beforeKeyboardState = inputService.KeyboardState;
        }
开发者ID:sgrizan,项目名称:Samples,代码行数:32,代码来源:DebugSceneBehavior.cs


示例6: HandleInput

        public void HandleInput(MouseState mouseState, KeyboardState keyboardState)
        {
            KeyboardState = keyboardState;

            if (MouseOverRenderArea && mouseState.LeftButton == ButtonState.Pressed)
            {
                if (!MouseDragging)
                {
                    MouseDragging = true;
                    MousePreviousPosition = new Vector2(mouseState.X, mouseState.Y);
                }

                var mouseNewCoords = new Vector2(mouseState.X, mouseState.Y);

                MouseDelta.X = mouseNewCoords.X - MousePreviousPosition.X;
                MouseDelta.Y = mouseNewCoords.Y - MousePreviousPosition.Y;

                MousePreviousPosition = mouseNewCoords;
            }

            if (!MouseOverRenderArea || mouseState.LeftButton == ButtonState.Released)
            {
                MouseDragging = false;
            }
        }
开发者ID:SteamDatabase,项目名称:ValveResourceFormat,代码行数:25,代码来源:Camera.cs


示例7: KeyboardInputProcessor

        public KeyboardInputProcessor()
        {
            _previousKeyboardState = new KeyboardState();
            _currentKeyboardState = new KeyboardState();

            KeyDictionary = new KeyDictionary();
        }
开发者ID:HaKDMoDz,项目名称:ProceduralGeneration,代码行数:7,代码来源:KeyboardInputProcessor.cs


示例8: Update

        public void Update(KeyboardState keyboardState)
        {
            _previousKeyboardState = _currentKeyboardState;
            _currentKeyboardState = keyboardState;

            KeyDictionary.Update(keyboardState);
        }
开发者ID:HaKDMoDz,项目名称:ProceduralGeneration,代码行数:7,代码来源:KeyboardInputProcessor.cs


示例9: Poll

        /// <summary>
        /// Check input device without check Floor Height 
        /// </summary>
        public void Poll()
        {
            KeyState = KeyBoardDevice.GetCurrentKeyboardState();
            KeyBoardJOBs();

            MState = MouseDevice.CurrentMouseState;
            MouseJOBs();
        }
开发者ID:Behzadkhosravifar,项目名称:Museum-3D,代码行数:11,代码来源:InputToolBox.cs


示例10: KeyboardMapBuilder

 internal KeyboardMapBuilder(IVirtualKeyboard virtualKeyboard)
 {
     _virtualKeyboard = virtualKeyboard;
     _keyboard = _virtualKeyboard.KeyboardState;
     _lookedForOem1ModifierVirtualKey = _keyboard.Oem1ModifierVirtualKey.HasValue;
     _lookedForOem2ModifierVirtualKey = _keyboard.Oem2ModifierVirtualKey.HasValue;
     _possibleModifierVirtualKey = new Lazy<List<uint>>(GetPossibleVirtualKeyModifiers);
 }
开发者ID:nligerakis,项目名称:VsVim,代码行数:8,代码来源:KeyboardMapBuilder.cs


示例11: Poll

        /// <summary>
        /// Check input device with check Floor Height 
        /// </summary>
        /// <param name="vFloor"></param>
        public void Poll(ref Microsoft.DirectX.Direct3D.CustomVertex.PositionTextured[] vFloor)
        {
            _vFloor = vFloor;
            KeyState = KeyBoardDevice.GetCurrentKeyboardState();
            KeyBoardJOBs();

            MState = MouseDevice.CurrentMouseState;
            MouseJOBs();
        }
开发者ID:Behzadkhosravifar,项目名称:Room-3D,代码行数:13,代码来源:InputToolBox.cs


示例12: Keyboard

 internal Keyboard(DKeyboard keyboard)
 {
     System.Diagnostics.Debug.Assert(keyboard != null);
     _dKeyboard = keyboard;
     _inputState = KeyboardInput.CreateEmpty();
     _lastPressedKeys = new List<Key>();
     (_timer = new GameTimer()).Start();
     _currentDirectInputState = new KeyboardState();
 }
开发者ID:sleepless1,项目名称:GameSharp,代码行数:9,代码来源:Keyboard.cs


示例13: 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


示例14: Update

        protected override void Update(TimeSpan gameTime)
        {
            this.input = WaveServices.Input;
            if (this.input.KeyboardState.IsConnected)
            {
                this.keyboardState = this.input.KeyboardState;

                RigidBody2D rigidBody = Owner.FindComponent<RigidBody2D>();
                if (rigidBody != null)
                {
                    // W, A, S, D applies Directional Linear Impulses
                    Vector2 result = Vector2.Zero;
                    if (keyboardState.A == ButtonState.Pressed)
                    {
                        result += leftDirection;
                    }
                    if (keyboardState.D == ButtonState.Pressed)
                    {
                        result -= leftDirection;
                    }
                    if (keyboardState.W == ButtonState.Pressed)
                    {
                        result += topDirection;
                    }
                    if (keyboardState.S == ButtonState.Pressed)
                    {
                        result -= topDirection;
                    }
                 
                    // Apply Linear Impulse
                    if (result != Vector2.Zero)
                    {
                        rigidBody.ApplyLinearImpulse(result);
                    }

                    // Left and Right arrow applies angular impulse
                    if (keyboardState.Left == ButtonState.Pressed)
                    {
                        rigidBody.ApplyAngularImpulse(-angularImpulse);
                    }
                    else if (keyboardState.Right == ButtonState.Pressed)
                    {
                        rigidBody.ApplyAngularImpulse(angularImpulse);
                    }

                    // J and K applies Torque
                    if (keyboardState.J == ButtonState.Pressed)
                    {
                        rigidBody.ApplyTorque(torque);
                    }
                    else if (keyboardState.K == ButtonState.Pressed)
                    {
                        rigidBody.ApplyTorque(-torque);
                    }
                }
            }
        }
开发者ID:123asd123A,项目名称:Samples,代码行数:57,代码来源:ForceBehavior.cs


示例15: InputSystem

 public InputSystem()
 {
     CurrentKeyboardState = new KeyboardState();
     PreviousKeyboardState = new KeyboardState();
     CurrentGamepadState = new GamePadState();
     PreviousGamepadState = new GamePadState();
     CurrentMouseState = new MouseState();
     PreviousMouseState = new MouseState();
 }
开发者ID:jasongdove,项目名称:MonoGameEngine,代码行数:9,代码来源:InputSystem.cs


示例16: Keyboard

        /// <summary>
        /// Hlavní konstruktor.
        /// </summary>
        /// <param name="window">Herní okno.</param>
        public Keyboard(GlibWindow window)
            : base(window)
        {
            keyboard = new KeyboardDirect(Input);
            keyboard.Properties.BufferSize = 128;
            keyboard.Acquire();

            state = new KeyboardState();
        }
开发者ID:mimic2300,项目名称:WormsGame,代码行数:13,代码来源:Keyboard.cs


示例17: PressAnyKey

 public static void PressAnyKey()
 {
     initializeKeyboard();
     while ((keyState = keyDevice.GetCurrentKeyboardState()) == null)
     {
         Application.DoEvents();
     }
     FreeKeyboard();
 }
开发者ID:weimingtom,项目名称:avgreader,代码行数:9,代码来源:KeyboardSrv.cs


示例18: Update

 /// <summary>
 /// Updates the DIKeyboard state.
 /// </summary>
 public override void Update()
 {
     try {
         _keys = _device.GetCurrentKeyboardState();
     }
     catch {
         // Lost access to keyboard.
         _acquireDevice();
     }
 }
开发者ID:soeminnminn,项目名称:BattleCity,代码行数:13,代码来源:DIKeyboard.cs


示例19: GetState

 public KeyboardState GetState()
 {
     lock (this.UpdateLock)
       {
     KeyboardState local_0 = new KeyboardState();
     foreach (KeyboardState item_0 in this.keyboards)
       local_0.MergeBits(item_0);
     return local_0;
       }
 }
开发者ID:tanis2000,项目名称:FEZ,代码行数:10,代码来源:WinRawKeyboard.cs


示例20: Update

        public void Update(KeyboardState keyboardState)
        {
            var array = _keys.Keys.ToArray();

            for (var i = 0; i < array.Length; i++)
            {
                var key = array[i];
                _keys[key] = keyboardState[key];
            }
        }
开发者ID:smoothdeveloper,项目名称:ProceduralGeneration,代码行数:10,代码来源:KeyDictionary.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Keycode类代码示例发布时间:2022-05-24
下一篇:
C# Keyboard类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap