So I am trying to make more than one sprite using a single class but I cannot seem to get the sprites to be drawn at all or drawn in different places (they are all just on top of one another).
In my Game1 I have:
Flag flag;
List<Flag> GameFlags = new List<Flag>();
then in LoadContent:
flag = new Flag();
tempTexture = Content.Load<Texture2D>("FlagTexture");
tempRectangle = new Rectangle(50, 500,tempTexture.Width / 3, tempTexture.Height / 3);
flag.SetSprite(tempTexture);
flag.SetRectangle(tempRectangle);
for (int i = 0; i < 2; i++)
{
GameFlags.Add(flag);
flag.spriteRectangle.X += 100;
}
Then in Draw:
foreach (Flag flag in GameFlags)
{
spriteBatch.Begin();
flag.Draw(spriteBatch);
spriteBatch.End();
}
The effect I am after is having 2 sprites spaced out by a specified amount of space. Image if the underscores were spacing and the zeros were sprites in the following:
0____________________________0
Any help and advice is appreciated.
Thanks in advance,
TeaBelliedTitch.
spriteBatch.Begin()
andspriteBatch.End()
calls out of the loop. You only need to call them once in this context. Put begin before the loop and end after. \$\endgroup\$