title: XNA c# Sprite remain after mouseclick
body: <p>I have a question.
  Is there a way to make sprite remain after mouseclick on it without making a List of sprites? I mean, my code generates sprite randomly at the screen and if I hit red sprite it dissappear. How to make red sprites stay on the screen after click?
  Here is my code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using Microsoft.Xna.Framework;
  using Microsoft.Xna.Framework.Audio;
  using Microsoft.Xna.Framework.Content;
  using Microsoft.Xna.Framework.GamerServices;
  using Microsoft.Xna.Framework.Graphics;
  using Microsoft.Xna.Framework.Input;
  using Microsoft.Xna.Framework.Media;
  
  namespace Ghost
  {
      public class Game1 : Microsoft.Xna.Framework.Game
      {
          GraphicsDeviceManager graphics;
          SpriteBatch spriteBatch;
          Texture2D ghostPic;
          Texture2D background;
          Random rand;
          int ghostColour;
          Rectangle ghostLocation;
          float timeRemaining;
          float showTime;
          int score;
          MouseState mouseState, mouseStatePrevious;
  
          public Game1()
          {
              graphics = new GraphicsDeviceManager(this);
              Content.RootDirectory = "Content";
          }
          protected override void Initialize()
          {
  
              graphics.PreferredBackBufferHeight = 550;
              graphics.PreferredBackBufferWidth = 750;
              this.IsMouseVisible = true;
              this.Window.Title = "Ghost Hunt | Score: 0";
              this.Window.AllowUserResizing = true;
              showTime = 0.5f;
              rand = new Random();
              base.Initialize();
          }
  
          protected override void LoadContent()
          {
              // Create a new SpriteBatch, which can be used to draw textures.
              spriteBatch = new SpriteBatch(GraphicsDevice);
              ghostPic = Content.Load&lt;Texture2D&gt;("GhostPic");
              background = Content.Load&lt;Texture2D&gt;("Background");
              // TODO: use this.Content to load your game content here
          }
  
          protected override void UnloadContent()
          {
              // TODO: Unload any non ContentManager content here
          }
          protected override void Update(GameTime gameTime)
          { 
              if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                  this.Exit();
              if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape))
                  this.Exit();
  
              mouseState = Mouse.GetState();
  
              if (mouseState.LeftButton == ButtonState.Pressed &amp;&amp; mouseStatePrevious.LeftButton == ButtonState.Released &amp;&amp; ghostLocation.Contains(mouseState.X, mouseState.Y))
              {
                  if (ghostColour == 0) score++;
                  if (ghostColour == 1)
                  {
                      score--;
  
                  }
                  this.Window.Title = "Ghost Hunt | Score: " + score.ToString();
                  timeRemaining = 0.0f;
              }
              else
              {
                  timeRemaining = MathHelper.Max(0, timeRemaining - (float)gameTime.ElapsedGameTime.TotalSeconds);
              }
              mouseStatePrevious = mouseState;
              if (timeRemaining == 0.0f)
              {
                  ghostColour = rand.Next(2);
                  ghostLocation = new Rectangle(rand.Next(GraphicsDevice.Viewport.Bounds.Width - ghostPic.Width), rand.Next(GraphicsDevice.Viewport.Bounds.Height - ghostPic.Height), ghostPic.Width / 2, ghostPic.Height / 2);
                  timeRemaining = showTime;
              }
  
              base.Update(gameTime);
          }
          protected override void Draw(GameTime gameTime)
          {
              GraphicsDevice.Clear(Color.CornflowerBlue);
  
              spriteBatch.Begin();
              spriteBatch.Draw(background, new Rectangle(0,0,GraphicsDevice.Viewport.Bounds.Width,GraphicsDevice.Viewport.Bounds.Height), Color.White);
              switch (ghostColour)
              {
                  case 0:
                      spriteBatch.Draw(ghostPic, ghostLocation, Color.White * 0.7f);
                      break;
                  case 1:
                      spriteBatch.Draw(ghostPic, ghostLocation, new Color(255,0,0,50));
                      break;
              } 
              spriteBatch.End();
  
              base.Draw(gameTime);
          }
      }
  }
  </code></pre>