public override void LoadContent() { if (m_content == null) { m_content = new ContentManager(ScreenManager.Game.Services, "Content"); } m_menu_fnt = m_content.Load <SpriteFont>("Fonts\\atarifont"); m_selector_txt = m_content.Load <Texture2D>("Pong\\Textures\\selector"); m_selector_snd = m_content.Load <SoundEffect>("Pong\\Sounds\\paddlehit"); m_resume = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("RESUME").X / 2, 150, "RESUME", m_menu_fnt); m_restart = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("RESTART").X / 2, 155 + m_resume.Height, "RESTART", m_menu_fnt); m_quit = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("QUIT").X / 2, 155 + m_resume.Height + m_restart.Height, "QUIT", m_menu_fnt); m_selector = new Sprite(m_selector_txt); m_selector.X_Pos = m_resume.X_Pos - (int)(m_selector.Width * 1.5); m_selector.Y_Pos = m_resume.Y_Pos + m_resume.Height / 2 - m_selector.Height / 2; // Hook up menu event handlers. m_resume.m_selected_events += OnCancel; m_restart.m_selected_events += RestartGameMenuEntrySelected; m_quit.m_selected_events += QuitGameMenuEntrySelected; // Add entries to the menu. MenuEntries.Add(m_resume); MenuEntries.Add(m_restart); MenuEntries.Add(m_quit); m_selected = m_resume; }
public override void LoadContent() { if (m_content == null) m_content = new ContentManager(ScreenManager.Game.Services, "Content"); m_menu_fnt = m_content.Load<SpriteFont>("Fonts\\atarifont"); m_selector_txt = m_content.Load<Texture2D>("Pong\\Textures\\selector"); m_selector_snd = m_content.Load<SoundEffect>("Pong\\Sounds\\paddlehit"); m_resume = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("RESUME").X/2, 150, "RESUME", m_menu_fnt); m_restart = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("RESTART").X / 2, 155 + m_resume.Height, "RESTART", m_menu_fnt); m_quit = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("QUIT").X / 2, 155 + m_resume.Height + m_restart.Height, "QUIT", m_menu_fnt); m_selector = new Sprite(m_selector_txt); m_selector.X_Pos = m_resume.X_Pos - (int)(m_selector.Width*1.5); m_selector.Y_Pos = m_resume.Y_Pos + m_resume.Height / 2 - m_selector.Height/2; // Hook up menu event handlers. m_resume.m_selected_events += OnCancel; m_restart.m_selected_events += RestartGameMenuEntrySelected; m_quit.m_selected_events += QuitGameMenuEntrySelected; // Add entries to the menu. MenuEntries.Add(m_resume); MenuEntries.Add(m_restart); MenuEntries.Add(m_quit); m_selected = m_resume; }
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); if (m_selected != SelectedItem) { m_selector_snd.Play(); m_selected = (MenuFontItem)SelectedItem; } m_selector.X_Pos = SelectedItem.X_Pos - (int)(m_selector.Width * 1.5); m_selector.Y_Pos = SelectedItem.Y_Pos + SelectedItem.Height / 2 - m_selector.Height / 2; m_selector.Update(); }
public override void LoadContent() { if (m_content == null) m_content = new ContentManager(ScreenManager.Game.Services, "Content"); m_fnt = m_content.Load<SpriteFont>("Fonts\\nesfont"); m_play = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_fnt.MeasureString("Play").X/2, 150, "Play", m_fnt); m_play.Selected_Tint = Color.Yellow; m_exit = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_fnt.MeasureString("Play").X/2, 155 + (int)m_fnt.MeasureString("Exit").Y, "Exit", m_fnt); m_exit.Selected_Tint = Color.Yellow; // Hook up menu event handlers. m_play.m_selected_events += PlayGameMenuEntrySelected; m_exit.m_selected_events += OnCancel; // Add entries to the menu. MenuEntries.Add(m_play); MenuEntries.Add(m_exit); }
public override void LoadContent() { if (m_content == null) { m_content = new ContentManager(ScreenManager.Game.Services, "Content"); } m_fnt = m_content.Load <SpriteFont>("Fonts\\nesfont"); m_play = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_fnt.MeasureString("Play").X / 2, 150, "Play", m_fnt); m_play.Selected_Tint = Color.Yellow; m_exit = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_fnt.MeasureString("Play").X / 2, 155 + (int)m_fnt.MeasureString("Exit").Y, "Exit", m_fnt); m_exit.Selected_Tint = Color.Yellow; // Hook up menu event handlers. m_play.m_selected_events += PlayGameMenuEntrySelected; m_exit.m_selected_events += OnCancel; // Add entries to the menu. MenuEntries.Add(m_play); MenuEntries.Add(m_exit); }
public override void LoadContent() { if (m_content == null) { m_content = new ContentManager(ScreenManager.Game.Services, "Content"); } m_duck_txt = m_content.Load <Texture2D>("DuckHunt\\Textures\\duck"); m_menu_fnt = m_content.Load <SpriteFont>("Fonts\\bigfont"); m_selector_snd = m_content.Load <SoundEffect>("DuckHunt\\Sounds\\select"); m_resume = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("RESUME").X / 2, 150, "RESUME", m_menu_fnt); m_restart = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("RESTART").X / 2, 155 + m_resume.Height, "RESTART", m_menu_fnt); m_quit = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("QUIT").X / 2, 160 + 2 * m_resume.Height, "QUIT", m_menu_fnt); m_selector = new AnimatedSprite(); m_selector.BuildAnimation(m_duck_txt, 1, 9, true, new int[4] { 3, 4, 5, 4 }); m_selector.SetFrame(0, 9, null); m_selector.SetFrame(1, 9, null); m_selector.SetFrame(2, 9, null); m_selector.SetFrame(3, 9, null); m_selector.X_Pos = m_resume.X_Pos - (int)(m_selector.Width * 1.5); m_selector.Y_Pos = m_resume.Y_Pos + m_resume.Height / 2 - m_selector.Height / 2; // Hook up menu event handlers. m_resume.m_selected_events += OnCancel; m_restart.m_selected_events += RestartGameMenuEntrySelected; m_quit.m_selected_events += QuitGameMenuEntrySelected; // Add entries to the menu. MenuEntries.Add(m_resume); MenuEntries.Add(m_restart); MenuEntries.Add(m_quit); m_selected = m_resume; }
public override void LoadContent() { if (m_content == null) m_content = new ContentManager(ScreenManager.Game.Services, "Content"); m_duck_txt = m_content.Load<Texture2D>("DuckHunt\\Textures\\duck"); m_menu_fnt = m_content.Load<SpriteFont>("Fonts\\bigfont"); m_selector_snd = m_content.Load<SoundEffect>("DuckHunt\\Sounds\\select"); m_resume = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("RESUME").X/2, 150, "RESUME", m_menu_fnt); m_restart = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("RESTART").X / 2, 155 + m_resume.Height, "RESTART", m_menu_fnt); m_quit = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("QUIT").X / 2, 160 + 2*m_resume.Height, "QUIT",m_menu_fnt); m_selector = new AnimatedSprite(); m_selector.BuildAnimation(m_duck_txt, 1, 9, true, new int[4] { 3, 4, 5, 4 }); m_selector.SetFrame(0, 9, null); m_selector.SetFrame(1, 9, null); m_selector.SetFrame(2, 9, null); m_selector.SetFrame(3, 9, null); m_selector.X_Pos = m_resume.X_Pos - (int)(m_selector.Width*1.5); m_selector.Y_Pos = m_resume.Y_Pos + m_resume.Height / 2 - m_selector.Height / 2; // Hook up menu event handlers. m_resume.m_selected_events += OnCancel; m_restart.m_selected_events += RestartGameMenuEntrySelected; m_quit.m_selected_events += QuitGameMenuEntrySelected; // Add entries to the menu. MenuEntries.Add(m_resume); MenuEntries.Add(m_restart); MenuEntries.Add(m_quit); m_selected = m_resume; }
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); if (m_selected != SelectedItem) { m_selector_snd.Play(); m_selected = (MenuFontItem)SelectedItem; } m_selector.X_Pos = SelectedItem.X_Pos - (int)(m_selector.Width * 1.5); m_selector.Y_Pos = SelectedItem.Y_Pos + SelectedItem.Height / 2 - m_selector.Height/2; m_selector.Update(); }