private void MakeGui() { GuiLabel buttonLabel = new GuiLabel(PLAY_TEXT, (SpriteFont)game.SharedContent[Consts.RESOURCE_FONT]); Point buttonSize = new Point(200, 50); Point buttonPosition = new Point(Consts.SCREEN_HORIZ_CENTER - buttonSize.X / 2, Consts.SCREEN_VERT_CENTER - buttonSize.Y / 2); GuiButton playButton = new GuiButton(new Rectangle(buttonPosition, buttonSize), Consts.BUTTON_NORMAL, Consts.BUTTON_HOVER, Consts.BUTTON_PRESSED, buttonLabel); playButton.OnClick += StartGameAction; AddElement(BUTTON_PLAY_ID, playButton); }
public GuiButton(Rectangle position, Color backColor, Color backColorHover, Color backColorPressed, GuiLabel label) { Rectangle = position; this.backColor = backColor; this.backColorHover = backColorHover; this.backColorPressed = backColorPressed; if (label != null) { this.label = label; Point textPosition = CalculateTextPosition(); this.label.Parent = this; this.label.SetRelativePosition(textPosition); } state = GuiElementState.Normal; }
private void MakeGui() { string scoreText = SCORE_TEXT + totalScore.ToString(); GuiLabel scoreLabel = new GuiLabel(scoreText, (SpriteFont)game.SharedContent[Consts.RESOURCE_FONT]); Point scorePosition = new Point(Consts.SCREEN_HORIZ_CENTER - scoreLabel.Rectangle.Width / 2, Consts.SCREEN_VERT_CENTER - scoreLabel.Rectangle.Height / 2); scoreLabel.SetRelativePosition(scorePosition); AddElement(LABEL_SCORE_ID, scoreLabel); GuiLabel gameOverLabel = new GuiLabel(GAME_OVER_TEXT, (SpriteFont)game.SharedContent[Consts.RESOURCE_FONT]); Point labelPosition = new Point(Consts.SCREEN_HORIZ_CENTER - gameOverLabel.Rectangle.Width / 2, scorePosition.Y - gameOverLabel.Rectangle.Height - 5); gameOverLabel.SetRelativePosition(labelPosition); AddElement(LABEL_GAME_OVER_ID, gameOverLabel); GuiLabel buttonLabel = new GuiLabel(OK_TEXT, (SpriteFont)game.SharedContent[Consts.RESOURCE_FONT]); Point buttonSize = new Point(200, 50); Point buttonPosition = new Point(Consts.SCREEN_HORIZ_CENTER - buttonSize.X / 2, scoreLabel.Rectangle.Bottom + 5); GuiButton okButton = new GuiButton(new Rectangle(buttonPosition, buttonSize), Consts.BUTTON_NORMAL, Consts.BUTTON_HOVER, Consts.BUTTON_PRESSED, buttonLabel); okButton.OnClick += RetryAction; AddElement(BUTTON_OK_ID, okButton); }