Exemple #1
0
        //
        public void draw(TextureRegion region, float x, float y, float width, float height, float originX = 0, float originY = 0, float scaleX = 1, float scaleY = 1, float rotation = 0, bool flipX = false, bool flipY = false)
        {
            sourceRect.X      = region.getRegionX();
            sourceRect.Y      = region.getRegionY();
            sourceRect.Width  = region.getRegionWidth();
            sourceRect.Height = region.getRegionHeight();


            origin.X = originX * (region.getRegionWidth() / width);
            origin.Y = originY * (region.getRegionHeight() / height);

            destRect.X      = (int)(x + originX);
            destRect.Y      = (int)(y + originY);
            destRect.Width  = (int)(width * scaleX);
            destRect.Height = (int)(height * scaleY);


            Draw(region.texture, destRect, sourceRect, currentColor, rotation, origin, (flipX ? SpriteEffects.FlipHorizontally : SpriteEffects.None) | (flipY? SpriteEffects.FlipVertically: SpriteEffects.None), 0);
        }
Exemple #2
0
 public void setRegion(TextureRegion region, int x, int y, int width, int height)
 {
     texture = region.texture;
     setRegion(region.getRegionX() + x, region.getRegionY() + y, width, height);
 }