/// <summary> /// Initialize buttons. /// </summary> void InitButtons() { // Just getting button dimensions player1Left = new Button(0, 0, ScreenManager); int buttonHeight = player1Left.GetHeight(); int buttonWidth = player1Left.GetWidth(); float upDownSpace = 2f; float leftRightSpace = 2f; int AHeight = 800;//ScreenManager.GraphicsDevice.Viewport.Height int AWidth = 480;//ScreenManager.GraphicsDevice.Viewport.Width player1Left = new Button(leftRightSpace, AHeight - upDownSpace - buttonHeight); player1Left.Selected += player1LeftSelected; buttons.Add(player1Left); player1Right = new Button(AWidth - leftRightSpace - buttonWidth, AHeight - upDownSpace - buttonHeight); player1Right.Selected += player1RightSelected; buttons.Add(player1Right); player2Right = new Button(leftRightSpace, upDownSpace); player2Right.Selected += player2RightSelected; buttons.Add(player2Right); player2Left = new Button(AWidth - leftRightSpace - buttonWidth, upDownSpace); player2Left.Selected += player2LeftSelected; buttons.Add(player2Left); }
/// <summary> /// Allows the screen to create the hit bounds for a particular menu entry. /// </summary> protected virtual Rectangle GetButtonHitBounds(Button button) { // the hit bounds are the entire width of the screen, and the height of the entry // with some additional padding above and below. return new Rectangle( (int)button.Position.X, (int)button.Position.Y, button.GetWidth(), button.GetHeight()); }