本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例5: GetButtonName
public string GetButtonName(Buttons key)
{
if (buttonStates.ContainsKey(key))
return key.ToString();
else
return null;
}
示例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;
}
示例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);
}
示例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;
}
}
}
示例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;
}
示例10: Start
void Start () {
selected = Buttons.newGame;
oldVal = selected;
highlightSelected (selected);
mousedOver = false;
ms = GameObject.Find ("Game Controller").GetComponent<MenuState>();
}
示例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;
}
示例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;
}
示例13: GetButtonHoldTime
public float GetButtonHoldTime(Buttons key)
{
if (buttonStates.ContainsKey(key))
return buttonStates[key].holdTime;
else
return 0;
}
示例14: Set
public void Set(string key, Buttons value)
{
if (Mapping.ContainsKey(key))
Mapping[key].Set(value);
else
Mapping.Add(key, new Button(value));
}
示例15: GetButtonValue
public bool GetButtonValue(Buttons key)
{
if (buttonStates.ContainsKey (key))
return buttonStates [key].value;
else
return false;
}