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


C# Input.Enter方法代码示例

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


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

示例1: Update

        public override void Update(GameTime gameTime, Input input)
        {
            soundSelect = TurkeySmashGame.content.Load<SoundEffect>("Sons\\menuSelect");
            SoundEffectInstance instanceSelect = soundSelect.CreateInstance();
            instanceSelect.Volume = 0.3f;
            instanceSelect.Pan = -0.9f;
            instanceSelect.Pitch = 0.9f;
            KeyboardState newStateK = Keyboard.GetState();
            GamePadState newStateG = GamePad.GetState(PlayerIndex.One);

            if ((oldStateK.IsKeyUp(Keys.Down) && newStateK.IsKeyDown(Keys.Down))
                            || (oldStateG.DPad.Down == ButtonState.Released && newStateG.DPad.Down == ButtonState.Pressed))
            {
                selecty++;
                instanceSelect.Play();
            }
            if (oldStateK.IsKeyUp(Keys.Up) && newStateK.IsKeyDown(Keys.Up)
                            || (oldStateG.DPad.Up == ButtonState.Released && newStateG.DPad.Up == ButtonState.Pressed))
            {
                selecty--;
                instanceSelect.Play();
            }

            if (selecty > boutons.Count)
                selecty = 1;

            if (selecty < 1)
                selecty = boutons.Count;

            foreach (IBouton bouton in boutons)
            {
                bouton.Etat = false;
            }
            boutons[selecty - 1].Etat = true;

            if (input.Enter() || GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed)
            {
                Thread.Sleep(200);

                soundEnter = TurkeySmashGame.content.Load<SoundEffect>("Sons\\latch_1");
                SoundEffectInstance instanceEnter = soundEnter.CreateInstance();
                instanceEnter.Volume = 0.2f;
                instanceEnter.Play();

                switch (selecty)
                {
                    case 1:
                        Bouton1();
                        break;
                    case 2:
                        Bouton2();
                        break;
                    case 3:
                        Bouton3();
                        break;
                    case 4:
                        Bouton4();
                        break;
                }
            }

            oldStateK = newStateK;
            oldStateG = newStateG;
        }
开发者ID:TurketSmash,项目名称:TurkeySmash,代码行数:64,代码来源:Menu.cs


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