public AnimationPlayer Play(string animation) { for (int i = 0; i < strips.Length; i++) { AnimationStrip strip = strips[i]; if (strip.Name == animation) { return(new AnimationPlayer(strip, texture, frameYArray[i])); } } return(null); }
public AnimationPlayer(AnimationStrip strip, Texture2D texture, int frameY) { this.strip = strip; this.texture = texture; int width = strip.FrameWidth; int height = strip.FrameHeight; // Every frame in an animation is assumed to have the same dimensions. sourceRect = new Rectangle(0, frameY, width, height); // Animation frames are assumed centered. origin = new Vector2(width, height) / 2; // Each frame is also assumed to have the same duration. frameDuration = strip.FrameRate; Color = Color.White; Scale = 1; }