Exemplo n.º 1
0
        // setDestinations fills an array with rectangle positions
        // Allows for easy fill of destination based on values.
        private void setDestinations(Rectangle[,] array, Texture2D image, int startX, int startY, int buffer)
        {
            int width = image.Width;
            int height = image.Height;

            int y = startY + buffer;
            for (int i = 0; i < array.GetLength(0); ++i) {
                int x = startX + buffer;
                for (int j = 0; j < array.GetLength(0); ++j) {
                    array[i, j] = new Rectangle(x, y, width, height);
                    if (j == 2 || j == 5) {
                        x += 10;
                    }
                    x += width + (buffer * 2);
                }
                if (i == 2 || i == 5) {
                    y += 10;
                }
                y += height + (buffer * 2);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Set the imageDimensions for this GameTexture
 /// </summary>
 /// <param name="dims">Array of Rectangles representing each image's dimension</param>
 public void setImageDimensions(Rectangle[] dims)
 {
     Array.Copy(dims, imageDimensions_, dims.GetLength(0));
 }
Exemplo n.º 3
0
 private void drawFromArray(Texture2D image, Rectangle[,] array)
 {
     for (int i = 0; i < array.GetLength(0); ++i) {
         for (int j = 0; j < array.GetLength(1); ++j) {
             spriteBatch.Draw(image, array[i, j], Color.White);
         }
     }
 }