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); }
public static LTextureRegion[][] Split(LTexture texture, int tileWidth, int tileHeight) { LTextureRegion region = new LTextureRegion(texture); return(region.Split(tileWidth, tileHeight)); }
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); }
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); }
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); }
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); }
public void Draw(LTextureRegion region, float x, float y) { Draw(region, x, y, 0); }
public LTextureRegion(LTextureRegion region, int x, int y, int width, int height) { SetRegion(region, x, y, width, height); }
public LTextureRegion(LTextureRegion region) { SetRegion(region); }
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; }
public void SetRegion(LTextureRegion region) { texture = region.texture; SetRegion(region.xOff, region.yOff, region.widthRatio, region.heightRatio); }
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); }
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++; }
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; }
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); }
public static LTextureRegion[][] Split(LTexture texture, int tileWidth, int tileHeight) { LTextureRegion region = new LTextureRegion(texture); return region.Split(tileWidth, tileHeight); }
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++; }