Example #1
0
 public void AddFrame(string bitmapName, int index)
 {
     if (index < 0 || index > frames.Count)
     {
         throw new IndexOutOfRangeException();
     }
     if (bitmapName == null || !atlas.HasValue(bitmapName))
     {
         frames.Insert(index, null);
     }
     else
     {
         frames.Insert(index, atlas.GetTexture(bitmapName));
     }
 }
Example #2
0
        public void SetTileName(int x, int y, string name)
        {
            if (x < 0)
            {
                throw new Exception("x cannot be less than zero.");
            }
            else if (x > numColumns)
            {
                throw new Exception("x cannot be greater than numColumns.");
            }
            if (y < 0)
            {
                throw new Exception("y cannot be less than zero.");
            }
            else if (y > numRows)
            {
                throw new Exception("y cannot be greater than numRows.");
            }

            if (name != null && atlas.HasValue(name))
            {
                if (bitmapNames[x, y] != name)
                {
                    bitmaps[x, y]     = atlas.GetBitmap(name);
                    bitmapNames[x, y] = name;
                    tilesChanged      = true;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(bitmapNames[x, y]))
                {
                    bitmaps[x, y]     = null;
                    bitmapNames[x, y] = null;
                    tilesChanged      = true;
                }
            }
        }