public virtual void play(string anim)
 {
     if (currentAnim == null || currentAnim.name != anim)
     {
         currentAnim = animations[anim];
         if (currentAnim != null)
         {
             currentAnim.play();
         }
     }
 }
        public bSpritemap(Texture2D image, int spriteWidth, int spriteHeight)
        {
            this.image = image;
            this._width = image.Width;
            this._height = image.Height;

            this.spriteWidth = spriteWidth;
            this.spriteHeight = spriteHeight;

            columns = _width / spriteWidth;
            rows = _height / spriteHeight;

            animations = new Dictionary<string, bAnim>();
            currentAnim = null;

            scaleX = 1;
            scaleY = 1;
        }
 public virtual void add(bAnim animation)
 {
     animations.Add(animation.name, animation);
 }
        protected Pair<bAnim, List<Point>> parseAnimation(Queue<string> lines)
        {
            Pair<bAnim, List<Point>> result;

            bAnim anim = null;

            string line = lines.Dequeue();
            string[] lineData = line.Split(' ');

            // Animation info: name frames speed
            string name = lineData[0];
            int frames = int.Parse(lineData[1]);
            float speed = float.Parse(lineData[2]);
            // There sould be enough lines to fill the expected frames
            if (frames > lines.Count)
                return null;

            // Parse each frame
            int[] frameList = new int[frames];
            List<Point> hotspots = new List<Point>();
            for (int i = 0; i < frames; i++)
            {
                // Frame info: index hotspotX hotspotY
                line = lines.Dequeue();
                lineData = line.Split(' ');
                frameList[i] = int.Parse(lineData[0]);
                hotspots.Add(new Point(int.Parse(lineData[1]), int.Parse(lineData[2])));
            }

            anim = new bAnim(name, frameList, speed, false);

            // Return result
            result = new Pair<bAnim, List<Point>>(anim, hotspots);
            return result;
        }