bool IsPressed(Buttons button) { return(game.IsPressed(button)); }
public virtual void Update(GameTime gameTime) { if (MainForm) { ClickHandled = false; } var n = controlChain.First; while (n != null) { n.Value.Update(gameTime); if (!ClickHandled) { if (n.Value.Visible) { n.Value.HandleInput(gameTime); if (GeometryHelper.Vectors2Rectangle(n.Value.Position, n.Value.Size).Intersects( new Rectangle((int)(MousePosition.X), (int)(MousePosition.Y), 1, 1))) { n.Value.IsMouseHovered = true; n.Value.Hovered(MousePosition); if (game.IsPressed(Keys.Space, Buttons.A) || game.IsMousePressed()) { n.Value.Held(MousePosition); } else { n.Value.IsMouseHold = false; } if (game.IsReleased(Keys.Space, Buttons.A) || game.IsMouseClicked()) { n.Value.Released(MousePosition); } if (game.IsTapped(Keys.Space, Buttons.A) || game.IsMouseClicked(false)) { n.Value.Pressed(MousePosition); } ClickHandled = true; } else { n.Value.IsMouseHovered = false; } #if KINECT if (Touch.Enabled) { foreach (var item in Touch.TrackPoints) { var pos = item.Position + MouseOffset; if (GeometryHelper.Vectors2Rectangle(n.Value.Position, n.Value.Size).Intersects( new Rectangle((int)(pos.X), (int)(pos.Y), 32, 32))) { n.Value.IsMouseHovered = true; n.Value.Hovered(pos); if (item.Pushed) { n.Value.IsMouseHold = true; n.Value.Held(pos); } if (item.LastHold && !item.Hold) { n.Value.Released(pos); //Touch.Reset(); } else if (!item.LastHold && item.Hold) { n.Value.Pressed(pos); //Touch.Reset(); } ClickHandled = true; } } } #endif } } n = n.Next; } #if WINDOWS if (HasMouse) { if (game.IsPressed(Keys.Right) || game.IsPressed(Buttons.LeftThumbstickRight)) { Mouse.SetPosition(Mouse.GetState().X + MouseSpeed, Mouse.GetState().Y); } else if (game.IsPressed(Keys.Left) || game.IsPressed(Buttons.LeftThumbstickLeft)) { Mouse.SetPosition(Mouse.GetState().X - MouseSpeed, Mouse.GetState().Y); } if (game.IsPressed(Keys.Up) || game.IsPressed(Buttons.LeftThumbstickUp)) { Mouse.SetPosition(Mouse.GetState().X, Mouse.GetState().Y - MouseSpeed); } else if (game.IsPressed(Keys.Down) || game.IsPressed(Buttons.LeftThumbstickDown)) { Mouse.SetPosition(Mouse.GetState().X, Mouse.GetState().Y + MouseSpeed); } } #elif WINDOWS_PHONE if (game.IsTouched()) { Vector2 p = game.GetHardestTouchPosition(); foreach (var item in objects) { if (game.IsTouched( Geometry2D.Vectors2Rectangle(item.Value.position, item.Value.size))) { item.Value.Pressed(); } } } #endif }