public static Animation GenerateAnimation(string assetName, int frameWidth, int frameHeight, int animLength, double animSpeed) { Animation _Animation = new Animation(); Texture2D _Texture = G.Content.Load<Texture2D>(assetName); int Cols = _Texture.Width / frameWidth; int Rows = _Texture.Height / frameHeight; _Animation.Frames = new List<Frame>(); _Animation.CurrentFrame = 0; _Animation._TotalFrames = animLength; // Cols* Rows; for (int j = 0; j < Rows; j++) for (int i = 0; i < Cols && j * Cols + i < animLength; i++) { Frame _Frame = new Frame(assetName, new Rectangle(i * frameWidth, j * frameHeight, frameWidth, frameHeight)); _Animation.Frames.Add(_Frame); } _Animation.AnimationSpeed = animSpeed; return _Animation; }
public Sprite(Frame frame, Vector2 startPosition) { _Frame = frame; _position = startPosition; _Color = Color.White; }