http://www.youtube.com/watch?v=EQ2Jmm4j ... re=related
the video shows what I want to do. Here is my xna code.
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XRpgLibrary;
using XRpgLibrary.InputHandlers;
using XRpgLibrary.Controls;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
namespace Client.GameScreens
{
public class CircleMenuScreen : BaseGameState
{
#region Field region
PictureBox backgroundImage;
PictureBox startGame;
PictureBox loadGame;
PictureBox exitGame;
Rectangle _startGame;
Rectangle _loadGame;
Rectangle _exitGame;
float maxItemWidth = 0f;
#endregion
#region Property Region
#endregion
#region Constructor Region
public CircleMenuScreen(Game game, GameStateManager manager)
: base(game, manager)
{
_startGame = new Rectangle(200, 200, 100, 100);
_loadGame = new Rectangle(150, 150, 100, 100);
_exitGame = new Rectangle(100, 100, 100, 100);
}
#endregion
#region XNA Method Region
public override void Initialize()
{
base.Initialize();
}
protected override void LoadContent()
{
base.LoadContent();
ContentManager Content = Game.Content;
backgroundImage = new PictureBox(
Content.Load<Texture2D>(@"Graphics\Backgrounds\titlescreen"),
GameRef.ScreenRectangle);
ControlManager.Add(backgroundImage);
startGame = new PictureBox(
Content.Load<Texture2D>(@"Graphics\GUI\start"),
_startGame);
startGame.Selected += new EventHandler(menuItem_Selected);
ControlManager.Add(startGame);
loadGame = new PictureBox(
Content.Load<Texture2D>(@"Graphics\GUI\load"),
_loadGame);
loadGame.Selected += menuItem_Selected;
ControlManager.Add(loadGame);
exitGame = new PictureBox(
Content.Load<Texture2D>(@"Graphics\GUI\exit"),
_exitGame);
exitGame.Selected += menuItem_Selected;
ControlManager.Add(exitGame);
ControlManager.NextControl();
ControlManager.FocusChanged += new EventHandler(ControlManager_FocusChanged);
ControlManager_FocusChanged(startGame, null);
}
void ControlManager_FocusChanged(object sender, EventArgs e)
{
Control control = sender as Control;
Vector2 position = new Vector2(control.Position.X + maxItemWidth + 10f, control.Position.Y);
}
private void menuItem_Selected(object sender, EventArgs e)
{
if (sender == startGame)
{
//StateManager.PushState(GameRef.CharacterGeneratorScreen);
}
if (sender == loadGame)
{
StateManager.PushState(GameRef.GamePlayScreen);
}
if (sender == exitGame)
{
GameRef.Exit();
}
}
public override void Update(GameTime gameTime)
{
if (InputHandler.ButtonPressed(Buttons.LeftThumbstickUp, PlayerIndex.One) ||
InputHandler.ButtonPressed(Buttons.DPadUp, PlayerIndex.One) ||
InputHandler.KeyPressed(Keys.Up))
if (InputHandler.ButtonPressed(Buttons.LeftThumbstickDown, PlayerIndex.One) ||
InputHandler.ButtonPressed(Buttons.DPadDown, PlayerIndex.One) ||
InputHandler.KeyPressed(Keys.Down))
if (_startGame.X == 200)
{
_startGame.X = 100;
_startGame.Y = 100;
_loadGame.X = 200;
_loadGame.Y = 200;
_exitGame.X = 150;
_exitGame.Y = 150;
}
else if (_startGame.X == 100)
{
_startGame.X = 150;
_startGame.Y = 150;
_loadGame.X = 100;
_loadGame.Y = 100;
_exitGame.X = 200;
_exitGame.Y = 200;
}
else if (_startGame.X == 150)
{
_startGame.X = 200;
_startGame.Y = 200;
_loadGame.X = 150;
_loadGame.Y = 150;
_exitGame.X = 100;
_exitGame.Y = 100;
}
base.Update(gameTime);
}
public override void Draw(GameTime gameTime)
{
GameRef.SpriteBatch.Begin();
base.Draw(gameTime);
ControlManager.Draw(GameRef.SpriteBatch);
GameRef.SpriteBatch.End();
}
#endregion
#region Game State Method Region
#endregion