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


C# Input.KeyboardState类代码示例

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


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

示例1: Update

        public override void Update()
        {
            // Bounding Box
            rectangle = new Rectangle
            (
                (int)Position.X,
                (int)Position.Y,
                (int)Size.X,
                (int)Size.Y
            );

            KeyboardState keyboardState = Keyboard.GetState();
            if (Keyboard.GetState().IsKeyDown(Keys.D))
            {
                Position += movingVector;
                body.ApplyLinearImpulse(movingImpulse);
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.A))
            {
                Position -= movingVector;
                body.ApplyLinearImpulse(-movingImpulse);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.W) && !prevKeyboardState.IsKeyDown(Keys.W))
            {
                if ((DateTime.Now - previousJump).TotalSeconds >= jumpInterval)
                {
                    jumpEffect.Play();
                    body.ApplyLinearImpulse(jumpingImpulse);
                    previousJump = DateTime.Now;
                }
            }

            prevKeyboardState = keyboardState;
        }
开发者ID:rolandKulcsar,项目名称:Crate-Game,代码行数:34,代码来源:Player.cs

示例2: move

        public override void move(ArrayList colidables)
        {
            KeyboardState newKeyBoardState = Keyboard.GetState();
            if (newKeyBoardState.IsKeyDown(Keys.Up))
            {
                if (checkCollision(colidables, 0, +velocity) == true)
                    y -= velocity;
            }
            else if (newKeyBoardState.IsKeyDown(Keys.Down))
            {
                if (checkCollision(colidables, 0, -velocity) == true)
                    y += velocity;
            }
            else if (newKeyBoardState.IsKeyDown(Keys.Left))
            {
                if (checkCollision(colidables, velocity, 0) == true)
                     x -= velocity;
            }
            else if (newKeyBoardState.IsKeyDown(Keys.Right))
            {
                if (checkCollision(colidables, -velocity, 0) == true)
                    x += velocity;
            }

            oldKeyBoardState = newKeyBoardState;
            hitBox = new Rectangle(x, y, width, height);
        }
开发者ID:idickson0,项目名称:Toggle,代码行数:27,代码来源:Player.cs

示例3: Update

        public int Update(GameTime gameTime)
        {
            KeyboardState keyState;
            keyState = Keyboard.GetState(PlayerIndex.One);

            if (keyState.IsKeyDown(Keys.Up) && !prevKeyState.IsKeyDown(Keys.Up))
            {
                if (selected > 0)
                {
                    selected--;
                }
            }

            if (keyState.IsKeyDown(Keys.Down) && !prevKeyState.IsKeyDown(Keys.Down))
            {
                if (selected < buttonList.Count - 1)
                {
                    selected++;
                }
            }

            if (keyState.IsKeyDown(Keys.Enter))
            {
                return selected;
            }

            prevKeyState = keyState;
            return -1;
        }
开发者ID:vaskosound,项目名称:JustCoyote,代码行数:29,代码来源:Menu.cs

示例4: Console

 private Console()
 {
     booleanValues = new Dictionary<string, bool>();
     floatValues = new Dictionary<string, float>();
     integerValues = new Dictionary<string, int>();
     integerValues.Add("consoleHeight", 512);
     integerValues.Add("consoleWidth", 768);
     integerValues.Add("consolePositionX", 64);
     integerValues.Add("consolePositionY", 64);
     integerValues.Add("consoleBorderWidth", 16);
     integerValues.Add("consoleAlpha", 220);
     booleanValues.Add("consoleActive", false);
     commandHistory = new ConsoleHistory(120);
     messageHistory = new ConsoleHistory(120);
     lines = new List<String>();
     currentCommand = "";
     lastState = new KeyboardState();
     booleanValues.Add("texInfo", false);
     booleanValues.Add("meshCountInfo", false);
     booleanValues.Add("showPosition", false);
     booleanValues.Add("occluderInfo", false);
     booleanValues.Add("drawshadowtex", false);
     booleanValues.Add("glow", true);
     floatValues.Add("hdrpower", 4.0f);
 }
开发者ID:slicedpan,项目名称:demo,代码行数:25,代码来源:Console.cs

示例5: Update

 public void Update()
 {
     previousMouseState = currentMouseState;
     previousKeyboardState = currentKeyboardState;
     currentMouseState = Mouse.GetState();
     currentKeyboardState = Keyboard.GetState();
 }
开发者ID:TheHappyCow,项目名称:TickTick,代码行数:7,代码来源:InputHelper.cs

示例6: Input

 public Input(MouseState cms, MouseState pms, KeyboardState cks, KeyboardState pks)
 {
     Pms = pms;
     Pks = pks;
     Cms = cms;
     Cks = cks;
 }
开发者ID:JaapSuter,项目名称:Pentacorn,代码行数:7,代码来源:Input.cs

示例7: HandleKeyboardInput

 public override void HandleKeyboardInput(KeyboardState oldKeyboardState)
 {
     KeyboardState currentKeyboardState = Keyboard.GetState();
     if (currentKeyboardState.IsKeyDown(Keys.Escape)
         && oldKeyboardState.IsKeyUp(Keys.Escape))
         videoPlayer.Stop();
 }
开发者ID:verngutz,项目名称:MoodSwing,代码行数:7,代码来源:MSIntroScreen.cs

示例8: kill

 public void kill(KeyboardState kb, MouseState ms)
 {
     stateTimer = 0.0f;
     state = State.EXIT;
     this.update(kb, ms);
     this.init();
 }
开发者ID:rhyok,项目名称:huewgj2013,代码行数:7,代码来源:AMinigame.cs

示例9: accessObject

        public void accessObject(LLESprite playerCharacter, KeyboardState keyboardState, KeyboardState prevKeyboardState)
        {
            mPlayerCharacter = playerCharacter;

            if (playerCharacter != null && (playerCharacter.getDirection() == LLESprite.DIRECTION_UP || playerCharacter.getDirection() == LLESprite.DIRECTION_LEFT_UP || playerCharacter.getDirection() == LLESprite.DIRECTION_RIGHT_UP)

                && keyboardState.IsKeyDown(Keys.Z) == true && prevKeyboardState.IsKeyDown(Keys.Z) == false)
            {
                for (int i = 0; i < mapObjects.Count; i++)
                {
                    if (mapObjects[i] != null && mapObjects[i].getSprite() != null)
                    {
                        LLESprite target = mapObjects[i].getSprite();

                        if (playerCharacter.isCollidingMap(new Vector4(target.getX(), target.getY(), target.getHeight(), target.getWidth()), new Vector2(cameraX, cameraY), false, true, 4) == true)
                        {
                            scriptProcessor.extractObjectVariables(mapObjects[i]);

                            attack = false;

                            break;
                        }
                    }
                }
            }
        }
开发者ID:caiodantas,项目名称:LemonLiteEngine,代码行数:26,代码来源:LLEMapFrontLayer.cs

示例10: Check

 public void Check(KeyboardState last, KeyboardState curr)
 {
     if (last == null)
         return;
     if (!matchMods(curr))
         return;
     switch (KeyEvent)
     {
         case KeyEvent.Released:
             if (!(keyDown(Key, last) && keyUp(Key, curr)))
                 return;
             break;
         case KeyEvent.Pressed:
             if (!(keyUp(Key, last) && keyDown(Key, curr)))
                 return;
             break;
         case KeyEvent.Down:
             if (!(keyDown(Key, curr)))
                 return;
             break;
         case KeyEvent.Up:
             if (!(keyUp(Key, curr)))
                 return;
             break;
         default:
             return;
     }
     // we made it through! Do something freakin' awesome
     CallDelegate();
 }
开发者ID:colbybhearn,项目名称:3DPhysics,代码行数:30,代码来源:KeyBinding.cs

示例11: Update

        public static void Update(MouseState mouse, KeyboardState keyboard)
        {
            MouseMoving(mouse);
            MouseClicking(mouse);

            DevInput(mouse, keyboard);
        }
开发者ID:Ascendzor,项目名称:Viper,代码行数:7,代码来源:Input.cs

示例12: Update

    public void Update(KeyboardState k)
    {
        PressedFire = IsPressed(k, Fire, FireKey);
        PressedBlock = IsPressed(k, Block, BlockKey);
        PressedSpecial = IsPressed(k, Special, SpecialKey);
        PressedUse = IsPressed(k, Use, UseKey);

        PressedUp = IsPressed(k, Up, UseKey);
        PressedLeft = IsPressed(k, Left, LeftKey);
        PressedRight = IsPressed(k, Right, RightKey);
        PressedDown = IsPressed(k, Down, DownKey);

        PressedInventoryR = IsPressed(k, InventoryR, InventoryRKey);
        PressedInventoryL = IsPressed(k, InventoryL, InventoryLKey);
        PressedStart = IsPressed(k, Start, StartKey);

        Fire = IsHeld(k, Fire, FireKey);
        Block = IsHeld(k, Block, BlockKey);
        Special = IsHeld(k, Special, SpecialKey);
        Use = IsHeld(k, Use, UseKey);

        Up = IsHeld(k, Up, UpKey);
        Left = IsHeld(k, Left, LeftKey);
        Right = IsHeld(k, Right, RightKey);
        Down = IsHeld(k, Down, DownKey);

        InventoryR = IsHeld(k, InventoryR, InventoryRKey);
        InventoryL = IsHeld(k, InventoryL, InventoryLKey);
        Start = IsHeld(k, Start, StartKey);
    }
开发者ID:WJLiddy,项目名称:CastleSpire,代码行数:30,代码来源:KeyboardInput.cs

示例13: Update

        public void Update(Player player, KeyboardState keyboard, MouseState mouse, Engine engine)
        {
            // Rortational Origin
            Rectangle originRect = new Rectangle((int)position.X, (int)position.Y,
                (int)texture.Width, (int)texture.Height);
            origin = new Vector2(originRect.Width / 2, originRect.Height / 2);

            int viewDistance = 200;

            double distance = Math.Sqrt(Math.Pow(player.position.X - position.X, 2) +
                Math.Pow(player.position.Y - position.Y, 2));

            if (distance < viewDistance)
            {
                float deltaX = player.position.X - position.X;
                float deltaY = player.position.Y - position.Y;
                float radians = (float)Math.Atan2(deltaY, deltaX);
                setRotation(radians);

                float zombieSpeed = 1.5f;
                float dx = (float) Math.Cos(rotation) * zombieSpeed;
                float dy = (float) Math.Sin(rotation) * zombieSpeed;
                position.X += dx;
                position.Y += dy;
            }
        }
开发者ID:nfsz,项目名称:Zombie,代码行数:26,代码来源:Zombie.cs

示例14: Update

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            currentstate = Keyboard.GetState();

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                Exit();

            // TODO: Add your update logic here
            else
            {
                if (currentstate.IsKeyDown(Keys.A) && !oldstate.IsKeyDown(Keys.A))
                {
                    sounds[0].Play();
                    //var sd = soundEffects[0].CreateInstance();
                    //sd.IsLooped = false;
                    //sd.Play();
                    //sd.Dispose();
                }
                if (currentstate.IsKeyDown(Keys.R) && !oldstate.IsKeyDown(Keys.R)) { rd.BMS파일분석(); }
                if (currentstate.IsKeyDown(Keys.Y) && !oldstate.IsKeyDown(Keys.Y)) { rd.노트시간계산();sdmgr.시간들 = rd.시간들; }
                if (currentstate.IsKeyDown(Keys.S) && !oldstate.IsKeyDown(Keys.S))
                {
                    sdmgr.Play();
                    //var sd = soundEffects[1].CreateInstance();
                    //sd.Play();
                }

                oldstate = currentstate;
            }
            

            base.Update(gameTime);
        }
开发者ID:ProjectEli,项目名称:BMS_Eli,代码行数:38,代码来源:GameMgr.cs

示例15: Initialize

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            oldstate = Keyboard.GetState();

            base.Initialize();
        }
开发者ID:ProjectEli,项目名称:BMS_Eli,代码行数:13,代码来源:GameMgr.cs


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