FlatRedBall.Content.SpriteGrid.DisplayRegionGridSave.ToDisplayRegionGrid C# (CSharp) Метод

ToDisplayRegionGrid() публичный Метод

public ToDisplayRegionGrid ( float gridSpacing ) : TextureGrid
gridSpacing float
Результат TextureGrid
        public TextureGrid<FloatRectangle> ToDisplayRegionGrid(float gridSpacing)
        {
            TextureGrid<FloatRectangle> toReturn = new TextureGrid<FloatRectangle>();

            toReturn.FirstPaintedX = FirstPaintedX;
            toReturn.LastPaintedX = new List<float>();

            toReturn.FirstPaintedY = FirstPaintedY;
            toReturn.LastPaintedY = toReturn.FirstPaintedY + (ReferenceGrid.Length - 1) * gridSpacing;

            toReturn.GridSpacingX = gridSpacing;
            toReturn.GridSpacingY = gridSpacing;

            int yOn = 0;

            //toReturn.BaseTexture = new FloatRectangle(0,1,0,1);

            foreach (FloatRectangle[] frArray in ReferenceGrid)
            {
                List<FloatRectangle> newFloatRectangleList =
                    new List<FloatRectangle>();
                toReturn.Textures.Add(newFloatRectangleList);

                toReturn.LastPaintedX.Add(toReturn.FirstPaintedX[yOn] + gridSpacing * (frArray.Length - 1));

                foreach (FloatRectangle rectangle in frArray)
                {
                    newFloatRectangleList.Add(rectangle);
                }

                yOn++;
            }


            return toReturn;

        }

Usage Example

Пример #1
0
        private void CreateDisplayRegionGrid(FlatRedBall.ManagedSpriteGroups.SpriteGrid spriteGrid)
        {
            #region Create the DisplayRegionGrid

            if (DisplayRegionGridSave != null)
            {
                TextureGrid <FloatRectangle> displayRegionGrid =
                    DisplayRegionGridSave.ToDisplayRegionGrid(GridSpacing);
                if (displayRegionGrid.BaseTexture == null)
                {
                    displayRegionGrid.BaseTexture = new FloatRectangle(
                        spriteGrid.Blueprint.TopTextureCoordinate,
                        spriteGrid.Blueprint.BottomTextureCoordinate,
                        spriteGrid.Blueprint.LeftTextureCoordinate,
                        spriteGrid.Blueprint.RightTextureCoordinate);
                }
                spriteGrid.DisplayRegionGrid = displayRegionGrid;
            }
            #endregion
        }