Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public MonoGameNinePatch(TextureRegion texture, int left, int right, int top, int bottom)
 {
     _textureRegion   = texture;
     _topHeight       = top;
     _leftWidth       = left;
     _middleWidth     = _textureRegion.getRegionWidth() - right - left;
     _rightWidth      = right;
     _middleHeight    = _textureRegion.getRegionHeight() - top - bottom;
     _bottomHeight    = bottom;
     _ninePatchRegion = new MonoGameTextureRegion(_textureRegion);
     _textureRegionX  = _textureRegion.getRegionX();
     _textureRegionY  = _textureRegion.getRegionY();
     _rightX          = _textureRegion.getRegionWidth() - right;
     _bottomY         = _textureRegion.getRegionHeight() - bottom;
 }
 public void setRegion(TextureRegion region, int x, int y, int width, int height)
 {
     _texture = region.getTexture();
     setRegion(region.getRegionX() + x, region.getRegionY() + y, width, height);
 }
Esempio n. 5
0
 private void add(TextureRegion region, out int posX, out int posY)
 {
     add(region.getTexture(), region.getRegionX(), region.getRegionY(), region.getRegionWidth(), region.getRegionHeight(), out posX, out posY);
 }