public PanningBackground(Game g, Character character, Texture2D image, SpriteBatch sb) : base(g) { this.character = character; this.image = image; this.sb = sb; charH = character.GetHeight(); charW = character.GetWidth(); speed = 5; }
/// <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); Texture2D planePic = Content.Load<Texture2D>("plane"); Texture2D background = Content.Load<Texture2D>("background"); Character aeroplane = new Character(this, planePic, GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2, 5, spriteBatch); PanningBackground bg = new PanningBackground(this, aeroplane, background, spriteBatch); aeroplane.Initialize(); bg.Initialize(); Components.Add(bg); Components.Add(aeroplane); aeroplane.SetBackground(bg); // TODO: use this.Content to load your game content here }