private void CreateControls() { Texture2D leftTexture = Game.Content.Load<Texture2D>(@"Textures\Interface\left_arrow"); Texture2D rightTexture = Game.Content.Load<Texture2D>(@"Textures\Interface\right_arrow"); Texture2D stopTexture = Game.Content.Load<Texture2D>(@"Textures\Interface\stop_bar"); backgroundImage = new PictureBox( Game.Content.Load<Texture2D>(@"Textures\Backgrounds\title_background"), GameRef.ScreenRectangle); ControlManager.Add(backgroundImage); Label label1 = new Label(); label1.Text = "Select your character"; label1.Size = label1.SpriteFont.MeasureString(label1.Text); label1.Position = new Vector2((GameRef.ScreenRectangle.Width - label1.Size.X) / 2, 135); ControlManager.Add(label1); characterSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture); characterSelector.SetItems(characterItems, 125); characterSelector.Position = new Vector2(label1.Position.X, 160); characterSelector.SelectionChanged += new EventHandler(selection_Changed); ControlManager.Add(characterSelector); LinkLabel linkLabel1 = new LinkLabel(); linkLabel1.Text = "Start."; linkLabel1.Position = new Vector2(label1.Position.X, 185); linkLabel1.Selected += new EventHandler(linkLabel1_Selected); ControlManager.Add(linkLabel1); characterImage = new PictureBox( characterImages[0], new Rectangle(10, 145, 40, 40), new Rectangle(0, 0, 20, 20)); ControlManager.Add(characterImage); ControlManager.NextControl(); }
protected override void LoadContent() { base.LoadContent(); ContentManager Content = Game.Content; backgroundImage = new PictureBox( Content.Load<Texture2D>(@"Textures\Backgrounds\title_background"), GameRef.ScreenRectangle); ControlManager.Add(backgroundImage); Texture2D arrowTexture = Content.Load<Texture2D>(@"Textures\Interface\left_arrow"); arrowImage = new PictureBox( arrowTexture, new Rectangle( 0, 0, arrowTexture.Width, arrowTexture.Height)); ControlManager.Add(arrowImage); startGame = new LinkLabel(); startGame.Text = "New Game"; startGame.Size = startGame.SpriteFont.MeasureString(startGame.Text); startGame.Selected += new EventHandler(menuItem_Selected); ControlManager.Add(startGame); loadGame = new LinkLabel(); loadGame.Text = "Load Game"; loadGame.Size = loadGame.SpriteFont.MeasureString(loadGame.Text); loadGame.Selected += menuItem_Selected; ControlManager.Add(loadGame); exitGame = new LinkLabel(); exitGame.Text = "Exit Game"; exitGame.Size = exitGame.SpriteFont.MeasureString(exitGame.Text); exitGame.Selected += menuItem_Selected; ControlManager.Add(exitGame); ControlManager.NextControl(); ControlManager.FocusChanged += new EventHandler(ControlManager_FocusChanged); Vector2 position = new Vector2(65, 150); foreach (Control c in ControlManager) { if (c is LinkLabel) { if (c.Size.X > maxItemWidth) maxItemWidth = c.Size.X; c.Position = position; position.Y += c.Size.Y + 5f; } } ControlManager_FocusChanged(startGame, null); }