so I have spent an hour searching google on how to reset gameTime.TotalGameTime.Seconds to zero. but from the looks of it you can't do that !!
why didn't microsoft just make a simple function ResetGameTime?!!!
SFML has it why XNA doesn't?
anyways here what i want to do. bascily I have a array of ten eneimes. and I want each enemy to spawn when time >=1. and then reset the time to 0;
so they don't spawn on top of each other.
here is my code:-
class MultipleEnemies
{
public Enemy[] enemy = new Enemy[10];
int SpawnNextEnemy;
SpriteFont Text;
double time;
public MultipleEnemies()
{
SpawnNextEnemy = 0;
}
public void Load(ContentManager Content)
{
for (int i = 0; i < 10 - 1; i++)
{
enemy = new Enemy();
enemy.LoadContent(Content);
Text = Content.Load<SpriteFont>("Fonts/Font");
}
}
public void Update(GameTime gameTime)
{
time = gameTime.TotalGameTime.Seconds;
for (int i = 0; i < SpawnNextEnemy; i++)
{
enemy.Update(gameTime);
}
if (time >= 1)
{
SpawnNextEnemy++;
time -= time;
if (SpawnNextEnemy >= 10)
SpawnNextEnemy = 9;
}
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.DrawString(Text, "SpawnNextEnemy=" + SpawnNextEnemy + "\ntime" + time, new Vector2(250, 0), Color.White);
for (int i = 0; i < SpawnNextEnemy; i++)
{
enemy.Draw(spriteBatch);
}
}
}