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 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 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++; }