title: Null reference exception for MissileFired.Move
body: <pre><code>namespace SpaceInvader
  {
      /// &lt;summary&gt;
      /// This is the main type for your game
      /// &lt;/summary&gt;
      public class SpaceInvaders : Microsoft.Xna.Framework.Game
      {
          GraphicsDeviceManager graphics;
          SpriteBatch spriteBatch;
  
          Texture2D StarfieldImg;
          Texture2D InvaderImg;
          Texture2D AltInvaderImg;
          Texture2D RocketLauncherImg;
          Texture2D MissileImg;
          int RocketXPos;
          int AlienDirection;
          int AlienSpeed;
          Invader[] Invaders; 
          double Ticks;
          Missile MissileFired;
  
          public SpaceInvaders()
          {
              graphics = new GraphicsDeviceManager(this);
  
              graphics.PreferredBackBufferWidth = 1024;
              graphics.PreferredBackBufferHeight = 768;
              graphics.ApplyChanges();
  
              Content.RootDirectory = "Content";
          }
  
          /// &lt;summary&gt;
          /// Allows the game to perform any initialization it needs to before starting to run.
          /// This is where it can query for any required services and load any non-graphic
          /// related content.  Calling base.Initialize will enumerate through any components
          /// and initialize them as well.
          /// &lt;/summary&gt;
          protected override void Initialize()
          {
              // TODO: Add your initialization logic here
              RocketXPos = 512;
  
              AlienDirection = -1;
              AlienSpeed = 16;
  
              Invaders = new Invader[11];
  
              int XPos = 512;
              for (int Count = 0; Count &lt; 11; Count++)
              {
                  Invaders[Count] = new Invader();
                  Invaders[Count].SetXPos(XPos);
                  Invaders[Count].SetYPos(100);
  
                  XPos = XPos + 32;
              }
  
              Ticks = 0;
  
              MissileFired = null;
              base.Initialize();
          }
  
          /// &lt;summary&gt;
          /// LoadContent will be called once per game and is the place to load
          /// all of your content.
          /// &lt;/summary&gt;
          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
              StarfieldImg = Content.Load&lt;Texture2D&gt;("Starfield1024x768");
              InvaderImg = Content.Load&lt;Texture2D&gt;("inv1");
              AltInvaderImg = Content.Load&lt;Texture2D&gt;("inv12");
              RocketLauncherImg = Content.Load&lt;Texture2D&gt;("LaserBase");
              MissileImg = Content.Load&lt;Texture2D&gt;("bullet");
  
          }
  
          /// &lt;summary&gt;
          /// UnloadContent will be called once per game and is the place to unload
          /// all content.
          /// &lt;/summary&gt;
          protected override void UnloadContent()
          {
              // TODO: Unload any non ContentManager content here
          }
  
          /// &lt;summary&gt;
          /// Allows the game to run logic such as updating the world,
          /// checking for collisions, gathering input, and playing audio.
          /// &lt;/summary&gt;
          /// &lt;param name="gameTime"&gt;Provides a snapshot of timing values.&lt;/param&gt;
          protected override void Update(GameTime gameTime)
          {
              // Allows the game to exit
              if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                  this.Exit();
  
              // TODO: Add your update logic here
              MissileFired.Move();
  
              if (Keyboard.GetState().IsKeyDown(Keys.Space))
              {
                  MissileFired = new Missile(RocketXPos, 650);
              }
  
              if (Keyboard.GetState().IsKeyDown(Keys.Left))
              {
                  RocketXPos = RocketXPos - 4;
              }
  
              if (Keyboard.GetState().IsKeyDown(Keys.Right))
              {
                  RocketXPos = RocketXPos + 4;
              }
  
              if (RocketXPos &lt; 100)
              {
                  RocketXPos = 100;
              }
  
              if (RocketXPos &gt; 924)
              {
                  RocketXPos = 924;
              }
  
              Ticks = Ticks + gameTime.ElapsedGameTime.TotalMilliseconds;
  
              if (Ticks &gt; 500)
              {
                  for (int Count = 0; Count &lt; 11; Count++)
                  {
                      Invaders[Count].MoveHorizontal(AlienSpeed * AlienDirection);
                  }
  
                  if (Invaders[0].GetXPos() &lt; 96)
                  {
                      AlienDirection = +1;
  
                      int XPos = 96;
                      for (int Count = 0; Count &lt; 11; Count++)
                      {
                          Invaders[Count].MoveVertical(4);
                          Invaders[Count].SetXPos(XPos);
                          XPos = XPos + InvaderImg.Width;
                      }
                  }
  
                  if (Invaders[10].GetXPos() &gt; 924)
                  {
                      AlienDirection = -1;
  
                      int XPos = 924 - InvaderImg.Width * 10;
                      for (int Count = 0; Count &lt; 11; Count++)
                      {
                          Invaders[Count].MoveVertical(4);
                          Invaders[Count].SetXPos(XPos);
                          XPos = XPos + InvaderImg.Width;
                      }
                  }
  
                  Ticks = 0;
              }
  
              base.Update(gameTime);
          }
  
  
          /// &lt;summary&gt;
          /// This is called when the game should draw itself.
          /// &lt;/summary&gt;
          /// &lt;param name="gameTime"&gt;Provides a snapshot of timing values.&lt;/param&gt;
          protected override void Draw(GameTime gameTime)
          {
              spriteBatch.Begin();
  
              spriteBatch.Draw(StarfieldImg, Vector2.Zero, Color.White);
  
              spriteBatch.Draw(RocketLauncherImg, new Vector2(RocketXPos, 650), Color.White);
  
              if (MissileFired != null)
              {
                  Vector2 MissilePos = new
                  Vector2(MissileFired.GetPosition().X, MissileFired.GetPosition().Y - MissileImg.Height);
              spriteBatch.Draw(MissileImg, MissilePos, Color.White);
              }
  
  
  
              for (int Count = 0; Count &lt; 11; Count++)
              {
                  spriteBatch.Draw(InvaderImg, Invaders[Count].GetPos(), Color.White);
              }
  
              spriteBatch.End();
  
              base.Draw(gameTime);
          }
      }
  }
  </code></pre>
  
  <p>When attempting to run this game, MissileFired.Move is underlined with a null reference exception. I think it may have something missing in the draw or update method but i have no clue. The detailed information about this exception states the "Object reference not set to an instance of an object." Help would be great, thank you!.</p>