Ejemplo n.º 1
0
 public void SetRegion(LTextureRegion region, int x, int y, int width,
                       int height)
 {
     texture = region.texture;
     SetRegion(region.GetRegionX() + x, region.GetRegionY() + y, width,
               height);
 }
Ejemplo n.º 2
0
        public static LTextureRegion[][] Split(LTexture texture, int tileWidth,
                                               int tileHeight)
        {
            LTextureRegion region = new LTextureRegion(texture);

            return(region.Split(tileWidth, tileHeight));
        }
Ejemplo n.º 3
0
 public SpriteRegion(LTextureRegion region)
 {
     SetRegion(region);
     SetColor(1f, 1f, 1f, 1f);
     SetSize(Math.Abs(region.GetRegionWidth()),
             Math.Abs(region.GetRegionHeight()));
     SetOrigin(width / 2, height / 2);
 }
Ejemplo n.º 4
0
 public SpriteRegion(LTextureRegion region, int srcX, int srcY,
         int srcWidth, int srcHeight)
 {
     SetRegion(region, srcX, srcY, srcWidth, srcHeight);
     SetColor(1f, 1f, 1f, 1f);
     SetSize(Math.Abs(srcWidth), Math.Abs(srcHeight));
     SetOrigin(width / 2, height / 2);
 }
Ejemplo n.º 5
0
        public LTextureRegion CreateTextureRegion(String name)
        {
            this.Pack();
            PackEntry entry = GetEntry(name);

            if (entry == null)
            {
                return(null);
            }
            LTextureRegion region = new LTextureRegion(texture, entry.bounds.left,
                                                       entry.bounds.top, entry.bounds.right, entry.bounds.bottom);

            return(region);
        }
Ejemplo n.º 6
0
        public LTextureRegion[][] Split(int tileWidth, int tileHeight)
        {
            int x      = GetRegionX();
            int y      = GetRegionY();
            int width  = GetRegionWidth();
            int height = GetRegionHeight();

            if (width < 0)
            {
                x     = x - width;
                width = -width;
            }

            if (height < 0)
            {
                y      = y - height;
                height = -height;
            }

            int rows = height / tileHeight;
            int cols = width / tileWidth;

            int startX = x;

            LTextureRegion[][] tiles = (LTextureRegion[][])CollectionUtils.XNA_CreateJaggedArray(typeof(LTextureRegion), rows, cols);
            for (int row = 0; row < rows; row++, y += tileHeight)
            {
                x = startX;
                for (int col = 0; col < cols; col++, x += tileWidth)
                {
                    tiles[row][col] = new LTextureRegion(texture, x, y, tileWidth,
                                                         tileHeight);
                }
            }

            return(tiles);
        }
Ejemplo n.º 7
0
 public void Draw(LTextureRegion region, float x, float y)
 {
     Draw(region, x, y, 0);
 }
Ejemplo n.º 8
0
 public LTextureRegion(LTextureRegion region, int x, int y, int width,
         int height)
 {
     SetRegion(region, x, y, width, height);
 }
Ejemplo n.º 9
0
 public LTextureRegion(LTextureRegion region)
 {
     SetRegion(region);
 }
Ejemplo n.º 10
0
        public LTextureRegion[][] Split(int tileWidth, int tileHeight)
        {
            int x = GetRegionX();
            int y = GetRegionY();
            int width = GetRegionWidth();
            int height = GetRegionHeight();

            if (width < 0)
            {
                x = x - width;
                width = -width;
            }

            if (height < 0)
            {
                y = y - height;
                height = -height;
            }

            int rows = height / tileHeight;
            int cols = width / tileWidth;

            int startX = x;
            LTextureRegion[][] tiles = (LTextureRegion[][])CollectionUtils.XNA_CreateJaggedArray(typeof(LTextureRegion), rows, cols);
            for (int row = 0; row < rows; row++, y += tileHeight)
            {
                x = startX;
                for (int col = 0; col < cols; col++, x += tileWidth)
                {
                    tiles[row][col] = new LTextureRegion(texture, x, y, tileWidth,
                            tileHeight);
                }
            }

            return tiles;
        }
Ejemplo n.º 11
0
 public void SetRegion(LTextureRegion region, int x, int y, int width,
         int height)
 {
     texture = region.texture;
     SetRegion(region.GetRegionX() + x, region.GetRegionY() + y, width,
             height);
 }
Ejemplo n.º 12
0
 public void SetRegion(LTextureRegion region)
 {
     texture = region.texture;
     SetRegion(region.xOff, region.yOff, region.widthRatio,
             region.heightRatio);
 }
Ejemplo n.º 13
0
 public LTextureRegion(LTextureRegion region, int x, int y, int width,
                       int height)
 {
     SetRegion(region, x, y, width, height);
 }
Ejemplo n.º 14
0
 public void Draw(LTextureRegion region, float x, float y, float originX,
     float originY, float width, float height, float scaleX,
     float scaleY, float rotation)
 {
     Draw(region, x, y, originX, originY, width, height, scaleX, scaleY, rotation);
 }
Ejemplo n.º 15
0
        public void Draw(LTextureRegion region, float x, float y, float rotation)
        {
            if (isClose)
            {
                return;
            }
            if (region == null)
            {
                return;
            }
            LTexture texture = region.texture;
            if (texture == null)
            {
                return;
            }

            if (!texture.isLoaded)
            {
                texture.LoadTexture();
            }

            float xOff = region.xOff;
            float yOff = region.yOff;
            float widthRatio = region.widthRatio;
            float heightRatio = region.heightRatio;

            texDst.X = (int)x;
            texDst.Y = (int)y;
            texDst.Width = region.GetRegionWidth();
            texDst.Height = region.GetRegionHeight();
            texSrc.X = region.dstX;
            texSrc.Y = region.dstY;
            texSrc.Width = region.dstWidth;
            texSrc.Height = region.dstHeight;

            Load(texture);

            if (rotation != 0)
            {
                float centerX = texSrc.Width / 2;
                float centerY = texSrc.Height / 2;
                texDst.X += (int)texture.Width / 2;
                texDst.Y += (int)texture.Height / 2;
                origin.X = centerX;
                origin.Y = centerY;
                batch.Draw(texture, texDst, texSrc, color, MathUtils.ToRadians(rotation), origin, SpriteEffects.None, 0);
            }
            else
            {
                batch.Draw(texture, texDst, texSrc, color);
            }
            idx++;
        }
Ejemplo n.º 16
0
 public LTextureRegion CreateTextureRegion(String name)
 {
     this.Pack();
     PackEntry entry = GetEntry(name);
     if (entry == null)
     {
         return null;
     }
     LTextureRegion region = new LTextureRegion(texture, entry.bounds.left,
             entry.bounds.top, entry.bounds.right, entry.bounds.bottom);
     return region;
 }
Ejemplo n.º 17
0
 public void SetRegion(LTextureRegion region)
 {
     texture = region.texture;
     SetRegion(region.xOff, region.yOff, region.widthRatio,
               region.heightRatio);
 }
Ejemplo n.º 18
0
 public void Draw(LTextureRegion region, float x, float y, float width,
         float height, float rotation)
 {
     Draw(region, x, y, region.GetRegionWidth() / 2,
             region.GetRegionHeight() / 2, width, height, 1f, 1f, rotation);
 }
Ejemplo n.º 19
0
 public static LTextureRegion[][] Split(LTexture texture, int tileWidth,
         int tileHeight)
 {
     LTextureRegion region = new LTextureRegion(texture);
     return region.Split(tileWidth, tileHeight);
 }
Ejemplo n.º 20
0
        public void Draw(LTextureRegion region, float x, float y, float originX,
            float originY, float width, float height, float scaleX,
            float scaleY, float rotation, bool clockwise)
        {
            if (isClose)
            {
                return;
            }
            if (region == null)
            {
                return;
            }
            LTexture texture = region.texture;
            if (texture == null)
            {
                return;
            }

            if (!texture.isLoaded)
            {
                texture.LoadTexture();
            }

            float xOff = region.xOff;
            float yOff = region.yOff;
            float widthRatio = region.widthRatio;
            float heightRatio = region.heightRatio;

            texDst.X = (int)x;
            texDst.Y = (int)y;
            texDst.Width = (int)(width * scaleX);
            texDst.Height = (int)(height * scaleY);
            texSrc.X = region.dstX;
            texSrc.Y = region.dstY;
            texSrc.Width = region.dstWidth;
            texSrc.Height = region.dstHeight;

            Load(texture);

            if (rotation != 0)
            {
                float centerX = texSrc.Width / 2;
                float centerY = texSrc.Height / 2;
                texDst.X += (int)texDst.Width / 2;
                texDst.Y += (int)texDst.Height / 2;
                origin.X = centerX;
                origin.Y = centerY;
                batch.Draw(texture.Texture, texDst, texSrc, color, MathUtils.ToRadians(rotation), origin, SpriteEffects.None, 0);
            }
            else if (originX != 0 || originX != 0)
            {
                texDst.X += (int)originX;
                texDst.Y += (int)originY;
                origin.X = originX;
                origin.Y = originY;
                batch.Draw(texture.Texture, texDst, texSrc, color, 0, origin, SpriteEffects.None, 0);
            }
            else
            {
                batch.Draw(texture.Texture, texDst, texSrc, color, 0, Vector2.Zero, SpriteEffects.None, 0);
            }
            idx++;
        }
Ejemplo n.º 21
0
 public LTextureRegion(LTextureRegion region)
 {
     SetRegion(region);
 }