Rotating menu in C#(for xna game)
Posted: Thu Aug 04, 2011 6:59 am
				
				On my old computer i use to have a tutorial for this saved via internet. To my dismay I don't have access to my old computer. 
http://www.youtube.com/watch?v=EQ2Jmm4j ... re=related
the video shows what I want to do. Here is my xna code.
the pictures show up no problem. the issue is getting them to actually move. I know I don't have them set up in a circle right now but this is just for testing purposes. So if any know a good tutorial on how to make this work thanks.. Also if you know a way to make the rotating smooth by all means please let me know.
			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
