Hi folks,
Apologies for asking a really simple question in the forums, but I'm hoping someone may be able to help me. I'm basically trying to create a very simple 2D XNA game in a week, from a background of not having programmed anything more complex than a VCR since Spectrum basic - it's for a magazine article, hence the need to cut a few corners when it comes to learning...
I have a problem which - I'm sure - the solution will provide me with a Eureka moment in understanding how this is done. I've followed the excellent videos on LearnXNA.com and the built-in tutorials and have figured out how to draw sprites on to the screen and move them around. It's not much, but it's a start... How do I then add in new sprites as the game progresses: for example, after 10 seconds of game time I want to create and set an new ball in motion. I've created a class for the moving ball, but I just can't see how to create a new instance at a predefined event and then include it in the Draw method...
Any help much appreciated - and credited in the mag.

Newbie question - spawning new objects
Igor.Gladyshev
bflemi3
Morn
Why are you trying to write a magazine article on a subject you're not familiar with
Is that really doing the readers of the magazine much of a service
Jurgen Willis
static
public ArrayList aliens = new ArrayList();Then when you add a new alien do...
Alien a = new Alien(sprite, position, col);
aliens.Add(a);
Then to loop through them to, say, Update or Render do...
foreach (Alien alien in aliens)
{
alien.Update(gameTime);
}
Hope that helps.
catalinione
fabal
For the timing, create a variable in the game class (say int _elapsedGameTime), set it to 0 in the Initialize event, and check in the Update event:
_elapsedGameTime += gameTime.ElapsedGameTime.Seconds;
if (_elapsedGameTime >= 10)
{
//spawn new ball
//reset the variable
_elapsedGameTime
}