Example #1
0
 /// <summary>
 /// Centers the GUIElement in the GameWindow
 /// </summary>
 /// <param name="windowSize"></param>
 public void CenterElement(Size windowSize)
 {
     guiRectangle = new Rectangle
         (
             (windowSize.width / 2) - (this.guiTexture.Width / 2),
             (windowSize.height / 2) - (this.guiTexture.Height / 2),
             guiTexture.Width,
             guiTexture.Height
         );
 }
Example #2
0
File: MainMenu.cs Project: jysr/TP
        /// <summary>
        /// Loads all content in the menu
        /// </summary>
        /// <param name="content">ContentManager</param>
        /// <param name="windowSize">the size of the GameWindow</param>
        public void LoadContent(ContentManager content, Size windowSize)
        {
            //Loads the content of our spritefont
            sf = content.Load<SpriteFont>("Graphics\\gameFont");

            //Loads the content of all other GUI elements
            for (int i = 0; i < menus.Count; i++)
            {
                foreach (GUIElement button in menus[i])
                {
                    button.LoadContent(content);
                    button.CenterElement(windowSize);
                }
            }
            //Sets offsets of the buttons
            menus[0].Find(x => x.ElementName == "Graphics\\player").MoveElement(0, -100);
            menus[0].Find(x => x.ElementName == "Graphics\\mine").MoveElement(0, -40);
            menus[1].Find(x => x.ElementName == "Graphics\\explosion").MoveElement(0, 60);
        }