Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Xml.Serialization;
- using Microsoft.Xna.Framework;
- using System.Collections;
- using System.Collections.Generic;
- using Microsoft.Xna.Framework.Storage;
- using System.IO;
- namespace RiskyRain2
- {
- [Serializable]
- public class AnimationData
- {
- Dictionary<string, Rectangle> spriteSourceRectangles = new Dictionary<string, Rectangle>();
- public AnimationData(string epath)
- {
- string path = epath;
- // open a StreamReader to read the index
- using (StreamReader reader = new StreamReader(path))
- {
- // while we're not done reading...
- while (!reader.EndOfStream)
- {
- // get a line
- string line = reader.ReadLine();
- // split at the equals sign
- string[] sides = line.Split('=');
- // trim the right side and split based on spaces
- string[] rectParts = sides[1].Trim().Split(' ');
- // create a rectangle from those parts
- Rectangle r = new Rectangle(
- int.Parse(rectParts[0]),
- int.Parse(rectParts[1]),
- int.Parse(rectParts[2]),
- int.Parse(rectParts[3]));
- // add the name and rectangle to the dictionary
- spriteSourceRectangles.Add(sides[0].Trim(), r);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement