Hi, i'm new to xna and c#... I don't know how to create sprites automatically and randomly because trying this:
When I debug comes out this error: NullReferenceException for "nextSpawn += (int)gameTime.ElapsedGameTime.TotalMilliseconds;" because the gameTime is null.I don't know what to do.Please help me, thank you!
From only what you have shown above, it looks like you never initialize the gameTime variable! I think what is needed here to help us help you is some more of your code, specifically where and how you are calling the update method!
It also looks you are not using a GameComponent to handle this update, in which XNA will take care of providing you with the current gameTime variable, so that might also be something you might want to look in to!
Hope this helps!
If you are using the XNA game framework the GameTime is passed to the update class for you as part of the XNA game loop.
All you need to do is call the Sprite.Update(gameTime) from the main Game.Update(GameTime gameTime) passing that gameTime to your sprite update method.
Something like that.