本文整理汇总了C#中Buttons类的典型用法代码示例。如果您正苦于以下问题:C# Buttons类的具体用法?C# Buttons怎么用?C# Buttons使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Buttons类属于命名空间,在下文中一共展示了Buttons类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: CreateGamepadDictionary
public static Dictionary<Buttons, String> CreateGamepadDictionary(Buttons gamePad)
{
Dictionary<Buttons, String> dictionary =
new Dictionary<Buttons, String>();
dictionary.Add(Buttons.A, "");
dictionary.Add(Buttons.B, "");
dictionary.Add(Buttons.X, "");
dictionary.Add(Buttons.Y, "");
dictionary.Add(Buttons.LeftShoulder, "");
dictionary.Add(Buttons.RightShoulder, "");
dictionary.Add(Buttons.LeftTrigger, "");
dictionary.Add(Buttons.RightTrigger, "");
dictionary.Add(Buttons.LeftStick, "");
dictionary.Add(Buttons.RightStick, "");
dictionary.Add(Buttons.Back, "");
dictionary.Add(Buttons.Start, "");
dictionary.Add(Buttons.DPadDown, "");
dictionary.Add(Buttons.DPadLeft, "");
dictionary.Add(Buttons.DPadRight, "");
dictionary.Add(Buttons.DPadUp, "");
dictionary.Add(Buttons.LeftThumbstickDown, "");
dictionary.Add(Buttons.LeftThumbstickLeft, "");
dictionary.Add(Buttons.LeftThumbstickRight, "");
dictionary.Add(Buttons.LeftThumbstickUp, "");
dictionary.Add(Buttons.RightThumbstickDown,"");
dictionary.Add(Buttons.RightThumbstickLeft, "");
dictionary.Add(Buttons.RightThumbstickRight,"");
dictionary.Add(Buttons.RightThumbstickUp,"");
return dictionary;
}
开发者ID:Bigtalljosh,项目名称:HydraEngine,代码行数:30,代码来源:Input.cs
示例17: InputAction
public InputAction(Buttons[] buttons, Keys[] keys, bool newPressOnly)
{
this.buttons = buttons != null ? buttons.Clone() as Buttons[] : new Buttons[0];
this.keys = keys != null ? keys.Clone() as Keys[] : new Keys[0];
this.newPressOnly = newPressOnly;
}
开发者ID:Nesokas,项目名称:hs,代码行数:7,代码来源:InputAction.cs
示例18: AddGamePadInput
public void AddGamePadInput(string theAction,
Buttons theButton,
bool isReleasedPreviously)
{
MyInput(theAction).AddGamepadInput(theButton,
isReleasedPreviously);
}
开发者ID:Vintharas,项目名称:WP7projects,代码行数:7,代码来源:GameInput.cs
示例19: GetButtonState
public static ButtonState GetButtonState(KeyboardState keyBoardState, Buttons b)
{
for (int i = 1; i <= (int)Input.Buttons.Y; i *= 2)
{
if (((int)b & i) == 0) continue;
if (b == Input.Buttons.LeftTrigger)
{
System.Diagnostics.Debug.WriteLine(string.Format("Is Pressed - "));
}
if (keyMappings.ContainsKey(b))
{
return keyBoardState.IsKeyDown(keyMappings[b]) ? ButtonState.Pressed : ButtonState.Released;
}
else
{
return ButtonState.Released;
}
}
return ButtonState.Released;
}
开发者ID:liwq-net,项目名称:SilverSprite,代码行数:25,代码来源:GamePadState.cs
示例20: LocalPlayer
public LocalPlayer(World world, Vector2 position, Category collisionCat, float scale, float limbStrength, float limbDefense, bool evilSkin, Color color, PlayerIndex player)
: base(world, position, collisionCat, scale, limbStrength, limbDefense, evilSkin, color)
{
this.player = player;
punchBtnPressed = punchKeyPressed = false;
kickBtnPressed = kickKeyPressed = false;
shootBtnPressed = shootKeyPressed = false;
trapBtnPressed = trapKeyPressed = false;
usesKeyboard = !GamePad.GetState(player).IsConnected;
lastShootAngle = 0f;
jumpBtn = Buttons.A;
rightBtn = Buttons.LeftThumbstickRight;
leftBtn = Buttons.LeftThumbstickLeft;
crouchBtn = Buttons.LeftTrigger;
punchBtn = Buttons.X;
kickBtn = Buttons.B;
shootBtn = Buttons.RightTrigger;
trapBtn = Buttons.Y;
upKey = Keys.W;
rightKey = Keys.D;
leftKey = Keys.A;
downKey = Keys.S;
trapKey = Keys.T;
}
开发者ID:TadCordle,项目名称:Project-Jack,代码行数:26,代码来源:LocalPlayer.cs
注:本文中的Buttons类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论