#region Using Statements using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Storage; #endregion namespace SpaceCarWars { class AnimatedSprite { private int fps; private Vector2 position = new Vector2(); private Vector2 velocity; private List texturesList = new List(); private Vector2 textureSize = new Vector2(20,40); // Temp Position private Color color = Color.White; #region Props public Vector2 Position { get { return position; } set { position = value; } } public Vector2 Velocity { get { return velocity; } set { velocity = value; } } public int FPS { get { return fps; } set { fps = value; } } public Vector2 TextureSize { get { return textureSize; } } #endregion public void AddFrames(Texture2D textureInput) { this.texturesList.Add(textureInput); } private void IterateFrames(List textures,SpriteBatch spriteBatch) { foreach (Texture2D texture in textures) { Vector2 positionVector = new Vector2(this.position.X, this.position.Y); Vector2 originVector = Vector2.Zero; Rectangle sourceRectangle = new Rectangle(0, 0, (int)this.textureSize.X, (int)this.textureSize.Y); spriteBatch.Draw(texture, positionVector, sourceRectangle, color, 0.0f, originVector, 1.0f, SpriteEffects.None, 0.5f); } } public void Draw(SpriteBatch spriteBatch) { IterateFrames(this.texturesList, spriteBatch); } } }