public void Initialize() { parallax = new ParallaxBackground(new Vector2D(0, 0), new Vector2D(-0.5f, -0.3f)); parallax.AddLayer("layer_1"); parallax.AddLayer("layer_1", new Vector2D(-1, -0.6f), parallax.DefaultPosition); parallax.Scale(0.5f); }
/// <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); try //To check if anything loads incorrectly. { MCharacter = new MC(Content, GraphicsDevice); background = new ParallaxBackground(GraphicsDevice); title = Content.Load <Texture2D>("Images/Title"); lose = Content.Load <Texture2D>("Images/Lose"); how = Content.Load <Texture2D>("Images/How"); menuSong = Content.Load <SoundEffect>("Sounds/MainMusic"); menuBackSong = menuSong.CreateInstance(); menuBackSong.IsLooped = true; inGameSong = Content.Load <SoundEffect>("Sounds/InGameMusic"); inGameBackSong = inGameSong.CreateInstance(); inGameBackSong.IsLooped = true; startSound = Content.Load <SoundEffect>("Sounds/Start"); background.AddLayer(Content.Load <Texture2D>("Images/Background"), 0, -100); background.AddLayer(Content.Load <Texture2D>("Images/AsteroidBack"), 1, -100); background.StartMoving(); verdana = Content.Load <SpriteFont>("Fonts/Verdana"); metalTex = Content.Load <Texture2D>("Images/metal"); for (int i = 0; i < beginning.Length; i++) { beginning[i] = new Sprite(metalTex, new Vector2(i * metalTex.Width * 0.05f + 50, 400), new Vector2(5, 0), false, 0.0f, 0.05f, SpriteEffects.None, null); } SpawnPlatforms(); } catch (ContentLoadException e) { System.Windows.Forms.MessageBox.Show(e.Message + " Please contact the programmers.", e.GetType().ToString()); Exit(); } }