Exemplo n.º 1
0
        /*
         * x == row
         * y == column
         */
        private void _assembleTextureAtlas(CTextureAtlas textureAtlas, int xStart = 0, int yStart = 0, bool reverse = false)
        {
            int xStartHold = xStart;
            int yStartHold = yStart;

            for (int y = 0; y <= _fixedHeight - 1; y++, yStart++)
            {
                xStart = xStartHold;
                for (int x = 0; x <= _fixedWidth - 1; x++, xStart++)
                {
                    //NOW the math is completely fine! :)
                    //The math is completely fine.
                    //this math seems a bit iffy due to the cellspacing, but we'll see how it goes! -Steve
                    int x0 = 0;
                    int y0 = 0;

                    if (reverse)
                    {
                        x0 = _fixedWidth - 1 - x;
                        y0 = _fixedHeight - 1 - y;
                    }
                    else
                    {
                        x0 = x;
                        y0 = y;
                    }

                    textureAtlas._textureAtlas[x0, y0] = new Rectangle
                                                             ((textureAtlas.FrameWidth + CellSpacing) * xStart, (textureAtlas.FrameHeight + CellSpacing) * yStart,
                                                             textureAtlas.FrameWidth,
                                                             textureAtlas.FrameHeight);
                }
            }
        }
Exemplo n.º 2
0
 public static void addTexture(string textureName, CTextureAtlas atlas)
 {
     if (!textures.ContainsKey(textureName))
     {
         textures.Add(textureName, atlas);
     }
 }
Exemplo n.º 3
0
 public CSprite(CTextureAtlas atlas, Effect shader = null, bool flipH = false, bool flipV = false, params VertexPositionColor[] vertices)
     : base(shader, vertices)
 {
     _imageAtlas = atlas;
     _size = new Rectangle(0,0, atlas.FrameWidth, atlas.FrameHeight);
     _name = _imageAtlas.sourceImage.Name;
     _flipH = flipH;
     _flipV = flipV;
     _totalFrames = atlas.tileXCount * atlas.tileYCount;
 }
Exemplo n.º 4
0
 public CSprite(string atlasName, CTextureAtlas atlas, Effect shader = null, bool flipH = false, bool flipV = false, params VertexPositionColor[] vertices)
     : base(shader, vertices)
 {
     _imageAtlas  = atlas;
     _atlasName   = atlasName;
     _size        = new Rectangle(0, 0, atlas.FrameWidth, atlas.FrameHeight);
     _name        = _imageAtlas.sourceImage.Name;
     _flipH       = flipH;
     _flipV       = flipV;
     _totalFrames = atlas.tileXCount * atlas.tileYCount;
 }
Exemplo n.º 5
0
 private void init(string atlasName, CTextureAtlas atlas, Effect shader = null, bool flipH = false, bool flipV = false, bool isEffect = false, int rotation = 0, params VertexPositionColor[] vertices)
 {
     _imageAtlas  = atlas;
     _atlasName   = atlasName;
     _size        = new Rectangle(0, 0, atlas.FrameWidth, atlas.FrameHeight);
     _name        = _imageAtlas.sourceImage.Name;
     _flipH       = flipH;
     _flipV       = flipV;
     _totalFrames = atlas.tileXCount * atlas.tileYCount;
     _isEffect    = isEffect;
     _rotation    = rotation;
 }
Exemplo n.º 6
0
 public CSprite(string atlasName, CTextureAtlas atlas, Effect shader = null, bool flipH = false, bool flipV = false, bool isEffect = false, params VertexPositionColor[] vertices)
     : base(shader, vertices)
 {
     init(atlasName, atlas, shader, flipH, flipV, isEffect, 0, vertices);
 }
Exemplo n.º 7
0
 public void clean()
 {
     _imageAtlas = null;
 }
Exemplo n.º 8
0
 /*
     * x == row
     * y == column
 */
 private void _assembleTextureAtlas(CTextureAtlas textureAtlas, int xStart = 0, int yStart = 0)
 {
     int xStartHold = xStart;
     int yStartHold = yStart;
     for (int y = 0; y <= _fixedHeight - 1; y++, yStart++)
     {
         xStart = xStartHold;
         for (int x = 0; x <= _fixedWidth - 1; x++, xStart++)
         {
             //NOW the math is completely fine! :)
             //The math is completely fine.
             //this math seems a bit iffy due to the cellspacing, but we'll see how it goes! -Steve
             textureAtlas._textureAtlas[x,y] = new Rectangle
                 ((textureAtlas.FrameWidth + CellSpacing) * xStart, (textureAtlas.FrameHeight + CellSpacing) * yStart,
                 textureAtlas.FrameWidth,
                 textureAtlas.FrameHeight);
         }
     }
 }
Exemplo n.º 9
0
 /*
     * x == row
     * y == column
     */
 private void _assembleTextureAtlas(CTextureAtlas textureAtlas)
 {
     for (int y = 0; y <= (textureAtlas.SourceImage.Bounds.Height / textureAtlas.FrameHeight) - 1; y++)
     {
         for (int x = 0; x <= (textureAtlas.SourceImage.Bounds.Width / textureAtlas.FrameWidth) - 1; x++)
         {
             textureAtlas._textureAtlas[x,y] = new Rectangle
                 (textureAtlas.FrameWidth * x, textureAtlas.FrameHeight * y,
                 textureAtlas.FrameWidth + textureAtlas.CellSpacing,
                 textureAtlas.FrameHeight + textureAtlas.CellSpacing);
         }
     }
 }