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


C# KeyboardState.Equals方法代码示例

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


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

示例1: update

        }  // Gå animeringen hos spelaren

    public Vector2 update(KeyboardState pressedKeys)
    {
            velocity.Y = 2;
            velocity.X = 2;
            
            #region movement
        // om w och eller a,d är nertryck kan man gå snett. Kan springa max agility velocity. agilityAccel är hur snabbt man kan springa till max hastigheten agility
        if (pressedKeys.IsKeyDown(Keys.W))
        {
                position.Y = position.Y -= velocity.Y;
        }

        if (pressedKeys.IsKeyDown(Keys.S))
        {
                position.Y = position.Y += velocity.Y;

        }

        if (pressedKeys.IsKeyDown(Keys.A))
        {
                position.X = position.X -= velocity.X;

        }

        if (pressedKeys.IsKeyDown(Keys.D))
        {
                position.X = position.X += velocity.X;

        }
        velocity.X = 0;
        velocity.Y = 0;
            #endregion

            #region ChangeWeaponAndKillThisInstance
            if (pressedKeys.Equals(Keys.D1)|| pressedKeys.Equals(Keys.D2)|| pressedKeys.Equals(Keys.D3))
            {
                if (pressedKeys.Equals(Keys.D1))
                {
                    type = "bow";
                }
               else if (pressedKeys.Equals(Keys.D2))
                {
                    type = "sword";
                }
               else if (pressedKeys.Equals(Keys.D3))
                {
                    type = "staff";
                }
                game1.changeWeapon(type, thisType);
         
                player = null;
       
            }
            #endregion
            
            return position;
    }
开发者ID:Abstractyyy,项目名称:GameWithJonthe,代码行数:59,代码来源:Player.cs

示例2: update

        public void update(GameTime gametime, KeyboardState current, KeyboardState previous)
        {
            if (current.IsKeyDown(Keys.Enter) && previous.IsKeyUp(Keys.Enter))
            {
                evaluate(information);
                information = "";
                return;
            }

            if (!previous.Equals(current))
            {
                for (int i = 0; i < previous.GetPressedKeys().Length; i++)
                {
                    bool notPressed = false;
                    for (int j = 0; j < current.GetPressedKeys().Length; j++)
                    {
                        if (current.GetPressedKeys()[j].Equals(previous.GetPressedKeys()[i]))
                            notPressed = true;
                    }

                    if (!notPressed)
                    {
                        if (previous.GetPressedKeys()[i].Equals(Keys.Space))
                            information += " ";
                        else if (previous.GetPressedKeys()[i].Equals(Keys.RightShift) ||
                            previous.GetPressedKeys()[i].Equals(Keys.LeftShift) ||
                            previous.GetPressedKeys()[i].Equals(Keys.RightAlt) ||
                            previous.GetPressedKeys()[i].Equals(Keys.LeftAlt) ||
                            previous.GetPressedKeys()[i].Equals(Keys.RightControl) ||
                            previous.GetPressedKeys()[i].Equals(Keys.LeftControl))
                            information += "";
                        else if (previous.GetPressedKeys()[i].Equals(Keys.OemComma))
                            information += ",";
                        else if (previous.GetPressedKeys()[i].Equals(Keys.OemPeriod))
                            information += ".";
                        else if (previous.GetPressedKeys()[i].Equals(Keys.OemQuestion))
                            information += "?";
                        else if (previous.GetPressedKeys()[i].Equals(Keys.OemMinus))
                            information += "-";
                        else if (previous.GetPressedKeys()[i].Equals(Keys.Back))
                        {
                            if (information.Length > 0)
                                information = information.Substring(0, information.Length - 1);
                        }
                        else if (previous.GetPressedKeys()[i].CompareTo(Keys.A) >= 0 && previous.GetPressedKeys()[i].CompareTo(Keys.Z) <= 0)
                        {
                            information += previous.GetPressedKeys()[i];
                        }
                        else if ((previous.GetPressedKeys()[i].CompareTo(Keys.D9) <= 0 && previous.GetPressedKeys()[i].CompareTo(Keys.D0) >= 0))
                        {
                            String parseD = (previous.GetPressedKeys()[i] + "");
                            information += parseD.Substring(1, parseD.Length - 1); ;
                        }
                    }
                }

            }
        }
开发者ID:Vergilreborn,项目名称:ACM_Projects,代码行数:58,代码来源:Debugging.cs


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