Texture2D spriteTexture; Vector2 spritePosition = new Vector2(100, 100); protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); spriteBatch.Draw(spriteTexture, spritePosition, Color.White); spriteBatch.End(); base.Draw(gameTime); }
Texture2D spriteTexture; Vector2[] spritePositions = new Vector2[] { new Vector2(100, 100), new Vector2(200, 200), new Vector2(300, 300) }; protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); foreach (Vector2 position in spritePositions) { spriteBatch.Draw(spriteTexture, position, Color.White); } spriteBatch.End(); base.Draw(gameTime); }This example shows how to draw multiple sprites on the screen with different positions. The `foreach` loop is used to iterate through the array of sprite positions and draw each sprite using the `Draw` method of the SpriteBatch class. Package library: Microsoft.Xna.Framework.Graphics.