/// <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); startMenu.LoadContent(Content, GraphicsDevice); float screenscaleX = graphics.GraphicsDevice.Viewport.Width / ViewPortWidth; float screenscaleY = graphics.GraphicsDevice.Viewport.Height / ViewPortHeight; SpriteScale = Matrix.CreateScale(screenscaleX, screenscaleY, 1); // TODO: use this.Content to load your game content here }
/// <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) { #if (ANDROID) // Get touch input bool gesturing = false; while (TouchPanel.IsGestureAvailable) { gesture = TouchPanel.ReadGesture(); gesturing = true; } // Start the game if (gesture.GestureType == GestureType.Tap) { gameState = GameState.Playing; } #endif CurrentKeyboardState = Keyboard.GetState(); if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { gameState = GameState.StartMenu; } // TODO: Add your update logic here if (gameState == GameState.StartMenu) { if (LoadedGameState != GameState.StartMenu) { Content.Unload(); startMenu = new StartMenuScreen(graphics); startMenu.Initialize(); startMenu.LoadContent(Content, GraphicsDevice); LoadedGameState = GameState.StartMenu; } startMenu.Update(gameTime); } if (gameState == GameState.OptionsMenu) { if (LoadedGameState != GameState.OptionsMenu) { Content.Unload(); optionsMenuScreen = new OptionsMenuScreen(); optionsMenuScreen.Initialize(); optionsMenuScreen.LoadContent(Content, GraphicsDevice); LoadedGameState = GameState.OptionsMenu; } optionsMenuScreen.Update(gameTime); } if (CurrentKeyboardState.IsKeyUp(Keys.P) && PreviousKeyboardState.IsKeyDown(Keys.P)) { if (gameState == GameState.Paused) { gameState = GameState.Playing; } else if (gameState == GameState.Playing) { gameState = GameState.Paused; } } if (gameState == GameState.Playing) { if (LoadedGameState != GameState.Playing) { Content.Unload(); gameScreen = new GameScreen(graphics); gameScreen.Initialize(Content, GraphicsDevice); gameScreen.LoadContent(Content, GraphicsDevice); LoadedGameState = GameState.Playing; } gameScreen.Update(gameTime, GraphicsDevice); } // Gameover goes to Start Menu for now if (gameState == GameState.GameOver) { if (LoadedGameState != GameState.GameOver) { Content.Unload(); gameOverScreen = new GameOverScreen(); gameOverScreen.Initialize(); gameOverScreen.LoadContent(Content, GraphicsDevice); LoadedGameState = GameState.GameOver; } gameOverScreen.Update(gameTime, GraphicsDevice); } #if (ANDROID) if (gesturing == false) { gesture = new GestureSample(); } #endif if (gameState == GameState.Exiting) { this.Exit(); } PreviousKeyboardState = Keyboard.GetState(); base.Update(gameTime); }