public AnimationClass Copy() { AnimationClass ac = new AnimationClass(); ac.Rectangles = Rectangles; ac.Color = Color; ac.Origin = Origin; ac.Rotation = Rotation; ac.Scale = Scale; ac.SpriteEffect = SpriteEffect; ac.IsLooping = IsLooping; return ac; }
public void AddAnimation(string name, int row, int frames, AnimationClass animation) { Rectangle[] recs = new Rectangle[frames]; for (int i = 0; i < frames; i++) { recs[i] = new Rectangle(i * width, (row - 1) * height, width, height); } //animation.Frames = frames; animation.Rectangles = recs; Animations.Add(name, animation); }
public void AddAnimation(StreamReader sr) { List<Rectangle> recs = new List<Rectangle>(); string line, name, currentName = null; string[] strs; int x, y, width, height; AnimationClass animation = new AnimationClass(); //line = sr.ReadLine(); while ((line = sr.ReadLine()) != null) { strs = line.Split(' '); //get the name <name>_<orientation>_<Action>-<FrameNumber> name = strs[0].Substring(0, strs[0].LastIndexOf('-')); if (currentName == null) currentName = name; else if (name != currentName) // we got all the frames for the animation { animation.Rectangles = recs.ToArray(); AddAnimation(currentName, animation); animation = new AnimationClass(); recs = new List<Rectangle>(); currentName = name; } x = Convert.ToInt32(strs[2]); y = Convert.ToInt32(strs[3]); width = Convert.ToInt32(strs[4]); height = Convert.ToInt32(strs[5]); recs.Add(new Rectangle(x, y, width, height)); } animation.Rectangles = recs.ToArray(); AddAnimation(currentName, animation); }
public void AddAnimation(string name, AnimationClass animation) { Animations.Add(name, animation); }