public void drawTextureRegion(TextureRegion textureRegion, float x, float y, float width, float height, float rotation) { if (textureRegion.getTexture().getUAddressMode() != _currentUMode || textureRegion.getTexture().getVAddressMode() != _currentVMode) { _currentUMode = textureRegion.getTexture().getUAddressMode(); _currentVMode = textureRegion.getTexture().getVAddressMode(); updateAddressMode(); } var sourceRectangle = new Rectangle(textureRegion.getRegionX(), textureRegion.getRegionY(), textureRegion.getRegionWidth(), textureRegion.getRegionHeight()); if (textureRegion.isFlipX()) { sourceRectangle.X -= sourceRectangle.Width; } if (textureRegion.isFlipY()) { sourceRectangle.Y -= sourceRectangle.Height; } _spriteBatch.Draw(((MonoGameTexture)textureRegion.getTexture()).texture2D, (new Vector2(x, y) + _translation - _rotationCenter) * _scale, sourceRectangle, _tint, rotation, Vector2.Zero, new Vector2(width / textureRegion.getRegionWidth(), height / textureRegion.getRegionHeight()) * _scale, (textureRegion.isFlipX() ? SpriteEffects.FlipHorizontally : SpriteEffects.None) | (textureRegion.isFlipY() ? SpriteEffects.FlipVertically : SpriteEffects.None), 0f); }
public void drawTextureRegion(TextureRegion textureRegion, float x, float y, float width, float height, float rotation) { beginRendering(); if (textureRegion.getTexture().getUAddressMode() != _currentUMode || textureRegion.getTexture().getVAddressMode() != _currentVMode) { _currentUMode = textureRegion.getTexture().getUAddressMode(); _currentVMode = textureRegion.getTexture().getVAddressMode(); updateAddressMode(); } _sharedSourceRectangle.X = textureRegion.getRegionX(); _sharedSourceRectangle.Y = textureRegion.getRegionY(); _sharedSourceRectangle.Width = textureRegion.getRegionWidth(); _sharedSourceRectangle.Height = textureRegion.getRegionHeight(); _sharedPositionVector.X = x; _sharedPositionVector.Y = y; _sharedScaleVector.X = width / textureRegion.getRegionWidth(); _sharedScaleVector.Y = height / textureRegion.getRegionHeight(); _spriteBatch.Draw(((MonoGameTexture)textureRegion.getTexture()).texture2D, _sharedPositionVector, _sharedSourceRectangle, _tint, rotation, Vector2.Zero, _sharedScaleVector, (textureRegion.isFlipX() ? SpriteEffects.FlipHorizontally : SpriteEffects.None) | (textureRegion.isFlipY() ? SpriteEffects.FlipVertically : SpriteEffects.None), 0f); }
public MonoGameSprite(TextureRegion region, int x, int y, int width, int height) : base(region, x, y, width, height) { setFlip(region.isFlipX(), region.isFlipY()); setOriginCenter(); }