I'm working on a SpaceWar-esque project to get comfortable with XNA. I have a Ship DrawableGameComponent and a Bullet DrawableGameComponent. The player's Ship is created at the start of the game, and the Bullets are created for each Ship as part of its constructor.
In my Ship constructor, I have the following code:
for (int i = 0; i < 5; i++)
{
activeBullets[i] = new Bullet(game);
}
The relevant part of my Ship's shoot() function is as follows:
activeBullets[bullet].Visible = true;
activeBullets[bullet].Enabled = true;
activeBullets[bullet].position = this.position;
The first five times I shoot() (that is, once for each bullet object that the ship is allotted), there is lag that I think is due to the bullet sprite being loaded. I've tried setting Visible and Enabled to true in the ship constructor loop where the Bullets are instantiated, but the first-five-shots lag persists. Any shots beyond the first five are completely lag-free.
How do I load the Bullets properly ahead of time so that there is no lag on the first shots?
LoadContent()
? \$\endgroup\$