/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { int selectedIndex = 0; KeyboardState ks = Keyboard.GetState(); if (startScene.Enabled) { selectedIndex = startScene.Menu.SelectedIndex; if (selectedIndex == 0 && ks.IsKeyDown(Keys.Enter)) { startScene.hide(); if (actionScene != null) { actionScene = null; actionScene = new ActionScene(this, spriteBatch); this.Components.Add(actionScene); } actionScene.show(); } else if (selectedIndex == 1 && ks.IsKeyDown(Keys.Enter)) { startScene.hide(); helpScene.show(); } else if (selectedIndex == 2 && ks.IsKeyDown(Keys.Enter)) { startScene.hide(); credit.show(); } else if (selectedIndex == 3 && ks.IsKeyDown(Keys.Enter)) { Exit(); } } if (!startScene.Enabled) { if (ks.IsKeyDown(Keys.Escape)) { hideAllScenes(); startScene.show(); } } // TODO: Add your update logic here base.Update(gameTime); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here startScene = new StartScene(this, spriteBatch); this.Components.Add(startScene); actionScene = new ActionScene(this, spriteBatch); this.Components.Add(actionScene); helpScene = new HelpScene(this, spriteBatch); this.Components.Add(helpScene); credit = new Credit(this, spriteBatch); this.Components.Add(credit); //instantiation ends //make startScene active startScene.show(); }