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


C# Buttons类代码示例

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


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

示例1: GameButton

 public GameButton(MouseButtons mouseCode)
 {
     this.keyCode = Keys.None;
     this.mouseCode = mouseCode;
     this.buttonCode = Buttons.None;
     this.inputType = InputType.MouseButton;
 }
开发者ID:trigger-death,项目名称:ZeldaOracle,代码行数:7,代码来源:GameButton.cs

示例2: GetButtonHelper

 public override string GetButtonHelper(Buttons button)
 {
     string buttonName = "";
     switch (button)
     {
         case Buttons.A:
             buttonName = getButtonName("1", "1", "1");
             break;
         case Buttons.B:
             buttonName = getButtonName("2", "2", "2");
             break;
         case Buttons.X:
             buttonName = getButtonName("0", "0", "0");
             break;
         case Buttons.Y:
             buttonName = getButtonName("3", "3", "3");
             break;
         case Buttons.LeftBumper:
             buttonName = getButtonName("4", "4", "4");
             break;
         case Buttons.RightBumper:
             buttonName = getButtonName("5", "5", "5");
             break;
         case Buttons.LeftStickClick:
             buttonName = getButtonName("10", "10", "10");
             break;
         case Buttons.RightStickClick:
             buttonName = getButtonName("11", "11", "11");
             break;
         case Buttons.Start:
             buttonName = getButtonName("9", "9", "9");
             break;
     }
     return buttonName;
 }
开发者ID:dvalles,项目名称:Rangers,代码行数:35,代码来源:PS4ControllerWrapper.cs

示例3: justReleased

 /// <summary>
 /// Returrns true if the specified button was just released
 /// </summary>
 /// <param name="Button">Buttons Button</param>
 /// <returns>bool</returns>
 public bool justReleased(Buttons button)
 {
     if ((old.IsButtonDown(button) && current.IsButtonUp(button)))
         return true;
     else
         return false;
 }
开发者ID:IndrekV,项目名称:MonoFlixel,代码行数:12,代码来源:FlxGamepad.cs

示例4: InputButton

 /// <summary>
 /// Creates a new InputButton from the given controller button.
 /// </summary>
 public InputButton(Buttons Button)
 {
     this._Key = 0; // Prevent complaining about readonly.
     this._KeyModifiers = 0;
     this._Button = Button;
     this.Type = InputMethod.Button;
 }
开发者ID:Octanum,项目名称:Corvus,代码行数:10,代码来源:InputButton.cs

示例5: GetButtonName

 public string GetButtonName(Buttons key)
 {
     if (buttonStates.ContainsKey(key))
         return key.ToString();
     else
         return null;
 }
开发者ID:bl2012,项目名称:teamugly,代码行数:7,代码来源:InputState.cs

示例6: ProcessButtonPress

    /// <summary>Called when a button on the game pad has been pressed</summary>
    /// <param name="button">Button that has been pressed</param>
    /// <returns>
    ///   True if the button press was processed by the control and future game pad
    ///   input belongs to the control until all buttons are released again
    /// </returns>
    internal bool ProcessButtonPress(Buttons button) {

      // If there's an activated control (one being held down by the mouse or having
      // accepted a previous button press), this control will get the button press
      // delivered, whether it wants to or not.
      if(this.activatedControl != null) {
        ++this.heldButtonCount;

        // If one of our children is the activated control, pass on the message
        if(this.activatedControl != this) {
          this.activatedControl.ProcessButtonPress(button);
        } else { // We're the activated control
          OnButtonPressed(button);
        }

        // We're already activated, so this button press is accepted in any case
        return true;
      }

      // A button has been pressed but no control is activated currently. This means we
      // have to look for a control which feels responsible for the button press,
      // starting with ourselves.

      // Does the user code in our derived class feel responsible for this button?
      // If so, we're the new activated control and the button has been handled.
      if(OnButtonPressed(button)) {
        this.activatedControl = this;
        ++this.heldButtonCount;
        return true;
      }

      // Nope, we have to ask our children to find a control that feels responsible.
      bool encounteredOrderingControl = false;
      for(int index = 0; index < this.children.Count; ++index) {
        Control child = this.children[index];

        // We only process one child that has the affectsOrdering field set. This
        // ensures that key presses will not be delivered to windows sitting behind
        // another window. Other siblings that are not windows are asked still, so
        // a bunch of buttons on the desktop would be asked in addition to a window.
        if(child.affectsOrdering) {
          if(encounteredOrderingControl) {
            continue;
          } else {
            encounteredOrderingControl = true;
          }
        }

        // Does this child feel responsible for the button press?
        if(child.ProcessButtonPress(button)) {
          this.activatedControl = child;
          ++this.heldButtonCount;
          return true;
        }
      }

      // Neither we nor any of our children felt responsible for the button. Give up.
      return false;

    }
开发者ID:pr0gramm3r1,项目名称:AngryTanks,代码行数:66,代码来源:Control.Input.cs

示例7: Init

        public void Init(ContentManager cm, float value, float minValue, float maxValue, string bgPath, string path, string t, Color bgColor, Color c, Vector2 targetPos, bool useOrigin, Vector2 hitboxOffset)
        {
            base.Init(cm, bgPath, path, t, bgColor, c, targetPos, useOrigin, hitboxOffset);

            sliderBackgroundTexture = new Sprite();
            sliderBlockTexture = new Sprite();
            valueText = new Text();
            backgroundTexture = new Sprite();
            sliderIcons = new Sprite();

            valueText.Init(cm, path, value.ToString(), Color.White, Vector2.Zero, true);
            backgroundTexture.Init(cm, bgPath, Vector2.Zero, Color.White, 1.0f, true);
            sliderIcons.Init(cm, "OptionsMenu\\sliderBarIcons", Vector2.Zero, Color.White, 1.0f, true);
            sliderBackgroundTexture.Init(cm, "OptionsMenu\\sliderBar", Vector2.Zero, Color.White, 1.0f, true);
            sliderBlockTexture.Init(cm, "OptionsMenu\\sliderBlock", Vector2.Zero, Color.White, 1.0f, true);

            this.value = value;
            this.minValue = minValue;
            this.maxValue = maxValue;

            sliderTargetPos = Vector2.Zero;

            holdTime = 0;
            incTick = 0;
            lastHeldKey = Keys.None;
            lastHeldButton = Buttons.B;

            fadeConstant = 0.1f;

            sliderHitbox = new Rectangle(0, 0, sliderBackgroundTexture.GetTexture.Width, sliderBackgroundTexture.GetTexture.Height);

            SetPos(startingPos);
            SetAlpha(0.0f);
        }
开发者ID:Nova-Spel,项目名称:Nova,代码行数:34,代码来源:Slider.cs

示例8: ControllerInput

        private void ControllerInput(PlayerIndex i, Buttons b, GamePadMessage m)
        {
            if (m == GamePadMessage.Pressed && b == Buttons.Start)
            {
                if (_players[i] == null)
                {
                    Vector2 spawnPos = GetSpawnPosition();

                    GameObject go = new GameObject(string.Format("player_{0}", i));
                    Console.WriteLine("Spawning Player: " + go.Name);
                    go.Transform.Position = spawnPos;
                    go.Transform.Scale = new Vector2(0.25f);
                    var p = go.AddComponent<Player>();
                    Model2D model = new Model2D(go, string.Format("Player\\hero{0}", (int)i + 1));
                    go.AddComponent(model);
                    model.UseAnimations = true;
                    var rigid = go.AddComponent<RigidBody>();
                    rigid.HasDrag = true;
                    p.Index = i;
                    _players[i] = p;
                    if (i == PlayerIndex.One)
                        Camera.Instance.TrackingObject = go;
                }
            }
        }
开发者ID:mlohstroh,项目名称:LXE,代码行数:25,代码来源:GameManager.cs

示例9: Holding

 /// <summary>
 /// Check if a mouse button is being held
 /// </summary>
 /// <param name="Key">The mouse button to check.</param>
 /// <returns>A True/False statement.</returns>
 public static bool Holding(Buttons Key)
 {
     if ((Key == Buttons.Left) && (M.LeftButton == ButtonState.Pressed)) return true;
     if ((Key == Buttons.Middle) && (M.MiddleButton == ButtonState.Pressed)) return true;
     if ((Key == Buttons.Right) && (M.RightButton == ButtonState.Pressed)) return true;
     return false;
 }
开发者ID:CodeTreeCommunity,项目名称:Shooter2D,代码行数:12,代码来源:Mouse.cs

示例10: Start

	void Start () {
		selected = Buttons.newGame;
        oldVal = selected;
		highlightSelected (selected);
        mousedOver = false;
		ms = GameObject.Find ("Game Controller").GetComponent<MenuState>();
	}
开发者ID:Obberton13,项目名称:ComS-309-Quarter,代码行数:7,代码来源:MenuManager.cs

示例11: ButtonPressed

        public bool ButtonPressed(Buttons button, bool repeat, bool delayRepeat)
        {
            bool returnValue = false;

            if (controlsActive == true)
            {
                if (repeat == true)
                {
                    if (delayRepeat == true)
                    {
                        returnValue = (currentGamePadState.IsButtonDown(button) && doRepeat);
                    }
                    else if (delayRepeat == false)
                    {
                        returnValue = currentGamePadState.IsButtonDown(button);
                    }
                }
                else if (repeat == false)
                {
                    returnValue = (currentGamePadState.IsButtonDown(button) && !previousGamePadState.IsButtonDown(button));
                }
            }
            else
            {
                returnValue = false;
            }

            if (returnValue == true)
            {
                lastButtonPress = gameTime.TotalGameTime;
            }

            return returnValue;
        }
开发者ID:amckendry,项目名称:FinalYearProject,代码行数:34,代码来源:GamePadController.cs

示例12: makeButton

            //every button needs to have own handler
            //bug Currently:
            //fontMat,font need to be set solid somewhere in a manager of sorts

            #region Creator

            //Creats a button and calls the need functions
            public static GameObject makeButton(Buttons bu, Transform parent, Vector3 pos = new Vector3(), int fontSize = 20, string text = "", int ToMenu = -1, string url = "", TextAnchor txmach = TextAnchor.UpperLeft)
            {
                GameObject b = null;
                switch (bu)
                {
                    case Buttons.Exit:
                       b = ExitButton.exitButton(fontMat, font, fontSize,txmach);
                        break;
                    case Buttons.ChangeMenu:
                        b = ChangeMenuButton.changeMenuButton(fontMat, font, fontSize, text, ToMenu, txmach);
                        break;
                    case Buttons.Link:
                        b = OpenLinkButton.openLinkButton(fontMat, font, fontSize, text, url, txmach);
                        break;
                    case Buttons.LevelLink:
                        b = menu.factory.button.LoadLevelButton.loadLevelButton(fontMat, font, fontSize, text, url, txmach);
                        break;
                    case Buttons.ResetHighScore:
                        b = ResetHighScoreButton.resetHighScoreButton(fontMat, font, fontSize, txmach);
                        break;
                    default:
                        b=new GameObject();
                        b.name="Buttons.##Error##";
                        Object.DestroyImmediate(b);
                        break;

                }
                b.transform.parent = parent;
                b.transform.position = pos;

                return b;
            }
开发者ID:nolimet,项目名称:GameJam2014,代码行数:39,代码来源:ButtonFactory.cs

示例13: GetButtonHoldTime

 public float GetButtonHoldTime(Buttons key)
 {
     if (buttonStates.ContainsKey(key))
         return buttonStates[key].holdTime;
     else
         return 0;
 }
开发者ID:pokeimon,项目名称:E-Sheep,代码行数:7,代码来源:InputState.cs

示例14: Set

 public void Set(string key, Buttons value)
 {
     if (Mapping.ContainsKey(key))
         Mapping[key].Set(value);
     else
         Mapping.Add(key, new Button(value));
 }
开发者ID:Sharparam,项目名称:DiseasedToast,代码行数:7,代码来源:GamePad.cs

示例15: GetButtonValue

 public bool GetButtonValue(Buttons key)
 {
     if (buttonStates.ContainsKey (key))
         return buttonStates [key].value;
     else
         return false;
 }
开发者ID:pokeimon,项目名称:E-Sheep,代码行数:7,代码来源:InputState.cs


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