本文整理汇总了C#中ButtonState类的典型用法代码示例。如果您正苦于以下问题:C# ButtonState类的具体用法?C# ButtonState怎么用?C# ButtonState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ButtonState类属于命名空间,在下文中一共展示了ButtonState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
void Update()
{
// pressing 1, 2 activate buttons in debug mode
if (Activated && Config.Debug && Input.GetKeyDown(KeyCode.Alpha1)) {
buttonState = ButtonState.LeftPressed;
leftMat.color = leftPressed;
rightMat.color = rightUnpressed;
leftAnimator.SetTrigger(Animator.StringToHash("Push"));
Debug.Log("Pressed left button");
} else if (Activated && Config.Debug && Input.GetKeyDown(KeyCode.Alpha2)) {
buttonState = ButtonState.RightPressed;
leftMat.color = leftUnpressed;
rightMat.color = rightPressed;
rightAnimator.SetTrigger(Animator.StringToHash("Push"));
Debug.Log("Pressed right button");
}
if (Activated && buttonState == ButtonState.LeftPressed) {
leftMat.color = leftPressed;
rightMat.color = rightUnpressed;
} else if (Activated && buttonState == ButtonState.RightPressed) {
leftMat.color = leftUnpressed;
rightMat.color = rightPressed;
}
}
示例2: Update
/// <summary>
/// This class performs an important function.
/// </summary>
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
mouseState = Mouse.GetState();
buttonState = mouseState.LeftButton;
if (Contains(mouseState.X, mouseState.Y))
{
foreach (AnswerWidget tmp in AnswerListWidget)
{
if (tmp.Contains(mouseState.X, mouseState.Y))
{
this.Scale = new Vector2(2, 1);
this.TintColor = Color.Red;
if ((buttonState == ButtonState.Pressed))
{
//Engine.Instance.ResolutionManager.ScreenSize = new Vector2(Width, Height);
}
else
{
this.Scale = new Vector2(1, 1);
this.TintColor = Color.Yellow;
}
}
}
}
}
示例3: HalfPadState
public HalfPadState(ControlSide side, PlayerIndex controllerIndex)
{
GamePadState gamePadState = GamePad.GetState(controllerIndex);
if (side == ControlSide.left)
{
stick1 = new Stick(gamePadState.ThumbSticks.Left);
stick2 = new Stick(gamePadState.DPad.Up,
gamePadState.DPad.Down,
gamePadState.DPad.Left,
gamePadState.DPad.Right);
Btn1 = gamePadState.Buttons.LeftShoulder;
Btn2 = (gamePadState.Triggers.Left < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; //TODO: test
Btn2AsTrigger = gamePadState.Triggers.Left;
Btn3 = gamePadState.Buttons.LeftStick;
BtnStart = gamePadState.Buttons.Back;
}
else //if (side == ControlSide.right)
{
stick1 = new Stick(gamePadState.ThumbSticks.Right);
stick2 = new Stick(gamePadState.Buttons.Y,
gamePadState.Buttons.A,
gamePadState.Buttons.X,
gamePadState.Buttons.B);
Btn1 = gamePadState.Buttons.RightShoulder;
Btn2 = (gamePadState.Triggers.Right < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; //TODO: test
Btn2AsTrigger = gamePadState.Triggers.Right;
Btn3 = gamePadState.Buttons.RightStick;
BtnStart = gamePadState.Buttons.Start;
}
}
示例4: FlickGesture
public FlickGesture()
{
AngleThreshold = 0.35f;
DistanceThreshold = 0.05f;
_previousState = ButtonState.Up;
_pointData = new List<PointF>();
}
示例5: GamePadDPad
public GamePadDPad (
ButtonState upValue,
ButtonState downValue,
ButtonState leftValue,
ButtonState rightValue )
{
}
示例6: InputState
/*public InputState(Stick LeftStick_WASD, Stick RightStick_Mouse,
ButtonState A_1, ButtonState X_2, ButtonState B_3, ButtonState Y_4,
ButtonState Dpad_UpArrow, ButtonState Dpad_DownArrow, ButtonState Dpad_RightArrow, ButtonState Dpad_LeftArrow,
ButtonState Select_TAB, ButtonState Start_ESC,
ButtonState LeftBumper_Q, ButtonState RightBumper_E,
ButtonState LeftTrigger_Mouse2, ButtonState RightTrigger_Mouse1,
float LeftTriggerAnalog = 0, float RightTriggerAnalog = 0)
{
this.LeftStick_WASD = LeftStick_WASD;
this.RightStick_Mouse = RightStick_Mouse;
this.A_1 = A_1;
this.X_2 = X_2;
this.B_3 = B_3;
this.Y_4 = Y_4;
this.Dpad_UpArrow = Dpad_UpArrow;
this.Dpad_DownArrow = Dpad_DownArrow;
this.Dpad_RightArrow = Dpad_RightArrow;
this.Dpad_LeftArrow = Dpad_LeftArrow;
this.Select_TAB = Select_TAB;
this.Start_ESC = Start_ESC;
this.LeftBumper_Q = LeftBumper_Q;
this.RightBumper_E = RightBumper_E;
this.LeftTrigger_Mouse2 = LeftTrigger_Mouse2;
this.RightTrigger_Mouse1 = RightTrigger_Mouse1;
this.LeftTriggerAnalog = LeftTriggerAnalog;
this.RightTriggerAnalog = RightTriggerAnalog;
}*/
//keyboard/mouse
public InputState(Stick LeftStick_WASD, Stick RightStick_Mouse,
ButtonState LeftTrigger_Mouse2, ButtonState RightTrigger_Mouse1,
bool A_1, bool X_2, bool B_3, bool Y_4,
bool Dpad_UpArrow, bool Dpad_DownArrow, bool Dpad_RightArrow, bool Dpad_LeftArrow,
bool Select_TAB, bool Start_ESC,
bool LeftBumper_Q, bool RightBumper_E,
float LeftTriggerAnalog = 0, float RightTriggerAnalog = 0)
{
this.LeftStick_WASD = LeftStick_WASD;
this.RightStick_Mouse = RightStick_Mouse;
this.LeftTrigger_Mouse2 = LeftTrigger_Mouse2;
this.RightTrigger_Mouse1 = RightTrigger_Mouse1;
this.A_1 = A_1 ? ButtonState.Pressed : ButtonState.Released;
this.X_2 = X_2 ? ButtonState.Pressed : ButtonState.Released;
this.B_3 = B_3 ? ButtonState.Pressed : ButtonState.Released;
this.Y_4 = Y_4 ? ButtonState.Pressed : ButtonState.Released;
this.Dpad_UpArrow = Dpad_UpArrow ? ButtonState.Pressed : ButtonState.Released;
this.Dpad_DownArrow = Dpad_DownArrow ? ButtonState.Pressed : ButtonState.Released;
this.Dpad_RightArrow = Dpad_RightArrow ? ButtonState.Pressed : ButtonState.Released;
this.Dpad_LeftArrow = Dpad_LeftArrow ? ButtonState.Pressed : ButtonState.Released;
this.Select_TAB = Select_TAB ? ButtonState.Pressed : ButtonState.Released;
this.Start_ESC = Start_ESC ? ButtonState.Pressed : ButtonState.Released;
this.LeftBumper_Q = LeftBumper_Q ? ButtonState.Pressed : ButtonState.Released;
this.RightBumper_E = RightBumper_E ? ButtonState.Pressed : ButtonState.Released;
this.LeftTriggerAnalog = LeftTriggerAnalog;
this.RightTriggerAnalog = RightTriggerAnalog;
}
示例7: StateChangedMethod
protected void StateChangedMethod(ButtonState prevState, ButtonState currState)
{
var backButtonTex = Resources.Load<Texture2D>(String.Format(@"Buttons/{0}", gameObject.GetComponent<SpriteRenderer>().sprite.texture.name.Replace(prevState.ToString(), currState.ToString())));
if (!backButtonTex) return;
gameObject.GetComponent<SpriteRenderer>().sprite = Sprite.Create(backButtonTex,
new Rect(0, 0, backButtonTex.width, backButtonTex.height), new Vector2(0, 0));
}
示例8: OnMouseUpAsButton
protected void OnMouseUpAsButton()
{
if (_State == ButtonState.Disabled) return;
_State = ButtonState.Over;
if(MethodOnClick != null)
MethodOnClick.DynamicInvoke();
}
示例9: ConvertFromButtonState
internal static RadioButtonState ConvertFromButtonState(ButtonState state, bool isHot)
{
if ((state & ButtonState.Checked) == ButtonState.Checked)
{
if ((state & ButtonState.Pushed) == ButtonState.Pushed)
{
return RadioButtonState.CheckedPressed;
}
if ((state & ButtonState.Inactive) == ButtonState.Inactive)
{
return RadioButtonState.CheckedDisabled;
}
if (isHot)
{
return RadioButtonState.CheckedHot;
}
return RadioButtonState.CheckedNormal;
}
if ((state & ButtonState.Pushed) == ButtonState.Pushed)
{
return RadioButtonState.UncheckedPressed;
}
if ((state & ButtonState.Inactive) == ButtonState.Inactive)
{
return RadioButtonState.UncheckedDisabled;
}
if (isHot)
{
return RadioButtonState.UncheckedHot;
}
return RadioButtonState.UncheckedNormal;
}
示例10: Update
public void Update()
{
if (ft)
{
ft = false;
return;
}
state = Mouse.GetState();
if (mousePos.X != state.X || mousePos.Y != state.Y)
moved = true;
else
moved = false;
mousePos.X = state.X;
mousePos.Y = state.Y;
d_mouse = new Vector2(state.X - lastState.X, state.Y - lastState.Y);
scrollWheelDelta = scrollWheelValue - state.ScrollWheelValue;
scrollWheelValue = state.ScrollWheelValue;
lmbState = state.LeftButton;
rmbState = state.RightButton;
isJustPressed = isJustReleased = false;
if (lmblastState == ButtonState.Pressed && lmbState == ButtonState.Released)
isJustReleased = true;
else if (lmblastState == ButtonState.Released && lmbState == ButtonState.Pressed)
isJustPressed = true;
lastState = state;
}
示例11: UpdateInput
public void UpdateInput(object sender, MouseInputEventArgs e)
{
if (MouseMode != e.Mode)
e.Mode = MouseMode;
X -= e.X;
Y -= e.Y;
WheelDelta += e.WheelDelta;
if (e.ButtonFlags == MouseButtonFlags.LeftDown)
LeftButton = ButtonState.Pressed;
if (e.ButtonFlags == MouseButtonFlags.LeftUp)
LeftButton = ButtonState.Released;
if (e.ButtonFlags == MouseButtonFlags.RightDown)
RightButton = ButtonState.Pressed;
if (e.ButtonFlags == MouseButtonFlags.RightUp)
RightButton = ButtonState.Released;
if (e.ButtonFlags == MouseButtonFlags.MiddleDown)
MiddleButton = ButtonState.Pressed;
if (e.ButtonFlags == MouseButtonFlags.MiddleUp)
MiddleButton = ButtonState.Released;
if (e.ButtonFlags == MouseButtonFlags.Button4Down)
Button4 = ButtonState.Pressed;
if (e.ButtonFlags == MouseButtonFlags.Button4Up)
Button4 = ButtonState.Released;
if (e.ButtonFlags == MouseButtonFlags.Button5Down)
Button5 = ButtonState.Pressed;
if (e.ButtonFlags == MouseButtonFlags.Button5Up)
Button5 = ButtonState.Released;
}
示例12: Update
public void Update(ButtonState up, ButtonState down, ButtonState left, ButtonState right)
{
this.Up = up == ButtonState.Pressed;
this.Down = down == ButtonState.Pressed;
this.Left = left == ButtonState.Pressed;
this.Right = right == ButtonState.Pressed;
}
示例13: IsClicked
public bool IsClicked()
{
MouseState tmp = Mouse.GetState();
bool b = ButtonState.Released == tmp.LeftButton && leftButtonState == ButtonState.Pressed;
leftButtonState = tmp.LeftButton;
return b && tmp.X >= X && tmp.X <= X + Texture.Width && tmp.Y >= Y && tmp.Y <= Y + Texture.Height;
}
示例14: Update
/// <summary>
/// Update method that will trigger click events as needed
/// </summary>
/// <param name="state"></param>
public void Update(ButtonState state)
{
if (state == ButtonState.Pressed && previousState != ButtonState.Pressed)
{
if (Pressed != null)
{
Pressed(this);
}
}
else if (state == ButtonState.Released && previousState == ButtonState.Pressed)
{
// For now, define a click as a release. In the future, maybe
// have click be more restrictive or even driven by components
// rather than a generic input handler
if (Clicked != null)
{
Clicked(this);
}
if (Released != null)
{
Released(this);
}
}
previousState = state;
}
示例15: ThreadButtonState
internal void ThreadButtonState()
{
int LastSearchTime = Config.ButtonStateUpdateInterval;
while (true)
{
if (Form.NTRConnection.HardwarePID != null)
{
SearchCriteria Criteria = new SearchCriteria();
Criteria.ProcessID = BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(Form.NTRConnection.HardwarePID), 0);
Criteria.DataType = DataTypeExact.Bytes1;
Criteria.StartAddress = BUTTON_STATES_START;
Criteria.Length = BUTTON_STATES_SIZE;
Criteria.SearchType = SearchTypeBase.Unknown;
Criteria.SearchValue = new byte[] { 0 };
Criteria.Size = 1;
Criteria.HideSearch = true;
Form.NTRConnection.SearchCriteria.Add(Criteria);
Form.NTRConnection.SendReadMemoryPacket(Criteria);
ButtonState = (ButtonState)Criteria.AddressesFound[BUTTON_STATES_START + Offset_Button][0];
ShoulderState = (ShoulderState)Criteria.AddressesFound[BUTTON_STATES_START + Offset_Shoulder][0];
StickState = (StickState)Criteria.AddressesFound[BUTTON_STATES_START + Offset_Stick][0];
StickHoriz = Criteria.AddressesFound[BUTTON_STATES_START + Offset_Horiz][0];
StickVert = Criteria.AddressesFound[BUTTON_STATES_START + Offset_Vert][0];
LastSearchTime = Math.Max(LastSearchTime, (int)Criteria.Duration);
Form.NTRConnection.SetCurrentOperationText2 = ButtonState.ToString() + "|" + ShoulderState.ToString() + "|" + StickState.ToString() + "|" + StickHoriz + "|" + StickVert + "|" + LastSearchTime;
}
Thread.Sleep(LastSearchTime * 2);
}
}