using System; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework; class Animation { protected Texture2D sprite; protected float frameTime; protected bool isLooping; public Animation(GameWorld gameWorld, string assetname, bool isLooping) { this.sprite = gameWorld.ResourceManager.getSprite(assetname); this.frameTime = 0.1f; this.isLooping = isLooping; } public Texture2D Sprite { get { return sprite; } } public float FrameTime { get { return frameTime; } } public bool IsLooping { get { return isLooping; } } public int CountFrames { get { return sprite.Width / sprite.Height; } } public int FrameWidth { get { return sprite.Height; } } public int FrameHeight { get { return sprite.Height; } } public Vector2 Origin { get { return new Vector2(FrameWidth / 2, FrameHeight); } } public Rectangle calculateFrame(int frameIndex) { return new Rectangle(frameIndex * FrameWidth, 0, FrameWidth, FrameHeight); } }